iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – UITableView自定义单元格滚动后消失的内容大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我已经看过很多次这里被问到这个问题,但没有一个解决方案对我有用.这是我的代码片段: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { static NSString *CellClassName = @"DemoTableViewC
@H_673_6@
@H_673_6@
我已经看过很多次这里被问到这个问题,但没有一个解决方案对我有用.这是我的代码片段:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath
{
    static NSString *CellClassName = @"DemoTableViewCell_sched";
    DemoTableViewCell_sched *cell = [tableView dequeueReusableCellWithIdentifier:CellClassName];

    if (cell == nil)
    {
        NSArray *topLevelItems = [cellLoader instantiateWith@R_673_11125@r:self options:nil];
        cell = [topLevelItems objectATindex:0];
    }
    cell.fooData = [self.bugs objectATindex:indexPath.row];    
    return cell;
}

然后我在ViewDidLoad中

cellLoader = [UINib nibWithNibName:@"DemoTableViewCell_sched" bundle:[NSBundle mainBundle]];

解决方法

就我而言,发生的事情是我没有保持对tableview的datasource的强大指针.因此,当滚动tableview时,数据源已经被释放并设置为nil,这导致tableview的numRowsForSection为0,而cellForRowATindexPath为nils.

如果有人遇到类似问题,您可能会查看是否正确保留了数据源和/或自定义对象.

大佬总结

以上是大佬教程为你收集整理的iphone – UITableView自定义单元格滚动后消失的内容全部内容,希望文章能够帮你解决iphone – UITableView自定义单元格滚动后消失的内容所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
猜你在找的iOS相关文章