我必须下载少量数据并在集合视图中显示所有信息。我正在for循环中下载数据。我想从服务器下载第一个数据后刷新UI。但在下载所有数据后,它正在刷新UI。这需要花费很多时间,显然用户不会等待这么久。一旦数据保存在本地,我就像这样刷新UI,
[[NSNotificationCenter defaultCenter] postNotificationName:@"refresh" object:self];
集合视图委托很晚才被调用。我应该如何处理这种情况。
答案 0 :(得分:0)
如果您使用NSNotificationCenter
刷新内容的方法有效,那么您应该在可能在块中调用的主线程上调用它。
只需将其包裹在当前代码中:
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"refresh" object:self];
});