我正在使用自定义表格 View 单元格,我的表格 View 显示索引 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;
}
请帮忙 提前致谢
最佳答案
您应该在另一个 else 语句中重置所有变量,这样当您的单元格被重用时,其中的变量就不会被重用。
else
{
cell.item = nil;
}
这应该可以解决你的问题。
关于ios - TableView 在某些索引后显示重复数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9664249/