ios - TableView 在某些索引后显示重复数据

标签 ios

我正在使用自定义表格 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/

相关文章:

ios - 更改 UISearchBar 的键盘颜色

ios - 某些日期的 DateFormatter.localizedString 已损坏

ios - IBM 工作灯 : Using native page in iOS

iphone - performSelectorOnMainThread 不执行

ios - 一个 View Controller 中的多个图形

ios - Realm 对象在写入前获取 `invalidated`,仅在第一次运行时

ios - 我们的 iOS 应用拒绝说明

ios - 我的 UIPickerview 输出可以与输入不同吗?

iphone - 导航 Controller 崩溃

ios - 在 Swift 中从 Uibezierpath 数组创建一个 UIImage