在我的 iPhone 应用程序中,我已经实现了侧边栏,即 JTRevealSideBar 以显示左侧的侧边栏,就像 facebook 应用程序一样但是,问题是它在单击侧边栏 tableview 后崩溃了第一个索引但对于其他索引它是完美的工作
崩溃日志 [sidebarViewController:didSelectObject:atIndexPath:]:消息发送到已释放实例 0xa58a950
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.sidebarDelegate)
{
SALSideBarViewCell * cell = (SALSideBarViewCell*)[tableView cellForRowAtIndexPath:indexPath];
NSObject *object = cell.titleLabel.text;
[self.sidebarDelegate sidebarViewController:self didSelectObject:object atIndexPath:indexPath];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"sidecell";
NSString * cellText;
SALSideBarViewCell * salcell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (salcell == nil) {
salcell = [[[SALSideBarViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
tableView.separatorColor = [UIColor clearColor];
if ([UIHelper isPad]) {
UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 60)] autorelease];
cellBackView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"sidebar_cell_pad.png"]];
salcell.backgroundView = cellBackView;
} else {
UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)] autorelease];
cellBackView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"sidebar_cell.png"]];
salcell.backgroundView = cellBackView;
}
}
if ( indexPath.section == 0 ) {
cellText = [dataArray objectAtIndex:indexPath.row];
if ( indexPath.row == 0 && self.slideDecksCount > 0 )
[salcell setValue:[NSString stringWithFormat:@"%d", self.slideDecksCount]];
else if ( indexPath.row == 1 && [[[RDStore sharedInstance] publicUsers] count] > 0 )
[salcell setValue:[NSString stringWithFormat:@"%d", [[[*** sharedInstance] ***] count]]];
else if ( indexPath.row == 2 && [[[RDStore sharedInstance] premiumUsers] count] > 0 )
[salcell setValue:[NSString stringWithFormat:@"%d", [[[*** sharedInstance] ***] count]]];
else if ( indexPath.row == 3 && [[[RDStore sharedInstance] tagCloudlabels] count] > 0 )
[salcell setValue:[NSString stringWithFormat:@"%d", [[[*** sharedInstance] ***] count]]];
else if ( [dataArray count] > 4 && indexPath.row == 4 && self.jsonDecksCount > 0 )
[salcell setValue:[NSString stringWithFormat:@"%d", self.jsonDecksCount]];
}
else {
cellText = [services objectAtIndex:indexPath.row];
}
salcell.titleLabel.text = cellText;
return salcell;
}
请告诉我错误在哪里谢谢