UITableView Custom Cells Disappearing content after Scrolling

前端 未结 10 1173
滥情空心
滥情空心 2020-12-17 00:12

I have seen this being asked here many times but none of the solutions worked for me. Here is my code snippet:

- (UITableViewCell *)tableView:(UITableView *)         


        
10条回答
  •  余生分开走
    2020-12-17 00:23

    In my case, what was happening was that I had not kept a strong pointer to the tableview's dataSource. So when the tableview was scrolled, the datasource had already been freed and set to nil, which led to the tableview getting 0 for numRowsForSection and nils for cellForRowAtIndexPath.

    If anyone has a similar problem, you might look if your datasource and/or custom objects are retained properly.

提交回复
热议问题