2015-11-01 98 views
-2

我必须下载少量数据并在聚集视图中显示所有信息。我正在for循环中下载数据。我想在从服务器下载第一个数据后刷新UI。但是,在下载所有数据后刷新UI。这是服用大量的时间,显然,用户不会这么快long.As等待的数据被保存在本地,我爽快这样UI,从iOS中的服务器下载数据后刷新UI

[[NSNotificationCenter defaultCenter] postNotificationName:@"refresh" object:self]; 

集合视图代表越来越叫得很晚。我应该如何处理这种情况。

+0

哪个线程并下载操作进行的? – Avi

回答

0

如果您的刷新内容的方法使用NSNotificationCenter有效,那么您应该在主线程上调用它,您可能在块中调用它。

只是包装围绕这个当前的代码:

dispatch_async(dispatch_get_main_queue(), ^{ 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"refresh" object:self]; 
}); 
+0

我试过了,但没有立即调用委托方法。刷新调用此方法: - - (void)refresh:(NSNotification *)notification { [[self collect] setDelegate:self]; [[self collect] setDataSource:self]; self.navigationItem.title = @“Title”; [[self alerts] reloadData]; [MBProgressHUD hideHUDForView:self.view animated:YES]; }它很快触及了这个方法,但委托人很晚才打电话...请帮助我 – Akshara