ios - UITableViewcell 未重用

标签 ios uitableview

下面显示的是我用来创建单元格的代码。该单元未被重复使用。每次 cell==nil 变为真。

我在 xib 中正确设置了标识符。请帮助我。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SRCourseListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

    if (cell == nil) {

        NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"SRCourseListCell" owner:self options:nil];
        cell=[nib objectAtIndex:0];

    }

    return cell;
}

最佳答案

在您的 SRCourseListCell 中,添加

- (NSString *) reuseIdentifier {
  return @"cell";
}

或者(因为你正在使用 nibs 可能是更好的解决方案),设置 identifier to "cell" in the inspector .

关于ios - UITableViewcell 未重用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17761804/

相关文章:

android - Azure 空间 anchor

ios - 从 VC 到 UILabel 的导出无效。 Outlet 无法连接到重复内容

ios - ios中日期的时区转换

ios - 关闭我使用 root 呈现的 ViewC Controller

ios - Facebook 原生广告在滚动后无法在 UITableView 单元格中再次点击

ios - insertRowsAtIndexPaths 中的 NSInternalInconsistencyException

ios - 为什么tableview的setSelected(_ :animated:) and setHighlighted(_:animated:) method called on init/load?

ios - 如何在没有快速播放器的情况下从 php 播放音乐

Swift Core 数据按天获取结果并排序到带有时间部分的表格 View 中

ios - 在tableview中搜索过滤后,为什么它显示空白单元格?