简体   繁体   中英

numberOfRowsInSection returns more than 0; cellForRowAtIndexPath still not being called

I notice this problem is very common and there are alot of posts about it but none of the solutions i tried so far worked.

So I have a delegate method that updates the datasource: NSArray * posts and reload the table view. I am positive that posts is updated before the reload call because i logged it.

It calls the numberOfRowInSection method and [posts count] returns more than 0 every time. but the cellForRowAtIndexPath is still not called.

the tableview is created from the IB and content is currently shows content and the cells before the reload. i need one of the cells content to be updated but it doesnt because cellForRowAtIndexPath is not called.

This only happens for the delegate method.

I tried making the reload call on the main thread using both gcd and perform selectorOnMainThread still no go.

Any ideas what maybe causing this problem and how to fix it?

Make sure you have UITableViewDataSource, UITableViewDelegate in your .h and connected the tableview delegate, data source and cellindentifier Cell in .xib.

have you registered your cell ?

[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

Load your tableView in method

awakeFromNib

this solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM