【发布时间】:2012-03-28 16:27:58
【问题描述】:
我正在使用自定义表格视图单元格和我的表格视图在索引 5 之后显示重复数据我不知道为什么会这样在 ipad 中它显示在索引 8 重复数据之后它可能是索引问题但找不到它下面是代码 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 静态 NSString *CellIdentifier = @"item";
ItemCell *cell = (ItemCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[ItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSLog(@"indexpath.row is %d",indexPath.row);
NSString *stre = [grouporphoto objectAtIndex:indexPath.row];
if([stre isEqualToString:@"Group"]){
folderimage = YES;
NSLog(@"here is folder");
cell.item = [items objectAtIndex:indexPath.row];
}
else if([stre isEqualToString:@"Photo"]){
folderimage = NO;
NSLog(@"here is Photo");
cell.item = [items objectAtIndex:indexPath.row];
}
return cell;
}
请帮忙 提前致谢
【问题讨论】:
-
难道你从来没有进入过ifs?
cell.item永远不会更新,这可以解释为什么你会得到重复的数据(重复使用的单元格)。将 NSLog 放在 ifs 之外,看看是否打印。
标签: ios