How to Reload a UITableView While I am Looking at It

旧城冷巷雨未停 提交于 2019-11-28 19:11:32
lostInTransit

Calling the reloadData method refreshes the data as soon as the method is called. It does not wait for the table to be scrolled. Make sure the data source (array or dictionary or wherever you've saved the values) is changed before you call reloadData.

Are you refreshing the data off the main thread? If so, you need to call the reloadData method using the following method:

- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait

So for a tableView it would be:

[tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];

Just a 2013 update, you should also be able to reload the data, just as long as you use

dispatch_async(dispatch_get_main_queue(), ^{
    [self.tableView reloadData];
});

GCD is awesome!

The following code help you to reload table while you looking that:

[self.tableView reloadData];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!