开发者

Reloading UITableView keeps old data

开发者 https://www.devze.com 2022-12-20 22:50 出处:网络
I have a custom view MyView : UIViewController <UITableViewDelegate, UITableViewDataSource> with a UITableView within (and some buttons and labels).

I have a custom view

MyView : UIViewController <UITableViewDelegate, UITableViewDataSource>

with a UITableView within (and some buttons and labels).

I have a notification from another view to populate the table with data form a sqlite3 database. I passed an array and after handle the notification I reload the table ([tableView reloadData]) with the new data (it has new data, I debug it).

Then it calls

(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

but doesn't refresh cells, it still old data. I debug and it re开发者_开发技巧loads but doesn't refresh data.

What's the problem? Can I clear old cells or something like that?


It sounds like you're probably setting the data in your cell == nil block after dequeueing it. In that case, move it out of that block and be sure that the data is set on every single cellForRowAtIndexPath call.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号