任何人都可以帮我performSelectorInBackground
?我想用performSelectorInBackground
中的更新数据重新载入表格。IPhone + performselector在后台
0
A
回答
4
你可以做的只是在后台线程中获取数据,一旦获取数据并更新主线程中的tableview,就可以返回主线程。
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//All your views cell creations and other stuff
[self performSelectorInBackground:@selector(loadDataThatToBeFetchedInThread:)
withObject:objectArrayThatNeedToFetchData];
}
- (void) loadDataThatToBeFetchedInThread:(NSArray *)objectThatNeedToFetchData
{
//Fetch the data here. which takes place in background thread
[self performSelectorOnMainThread:@selector(updateTableViewWithTheData:)
withObject:responseData
waitUntilDone:YES];
}
- (void) updateTableViewWithTheData:(NSMutableArray *)yourData
{
//Update Data to tableview here
}
+0
对不起,我只能给一个+1 :) – 2012-03-20 09:23:07
+0
^非常感谢,我一定会试一试 – Shantanu 2012-03-20 11:37:19
0
所有的UI功能都应该在主线程中完成。所以你必须在主线程中重新加载UITableView。
+0
看起来像一个很棒的评论!但也许你看看这个问题! – 2015-04-29 09:54:38
相关问题
- 1. PerformSelector延迟后不运行在后台模式 - iPhone
- 2. IPhone performSelector issue
- 3. MBProgressHUD和performselector问题 - iphone
- 4. 在For循环中使用performSelector? iPhone
- 5. (iphone)pushViewController在后台线程?
- 6. iPhone - 在后台录音
- 7. 后台任务iPhone
- 8. iPhone如何取消停止performSelector
- 9. 需要在performSelector之后调用NSAutoReleasePool:withObject:afterDelay?
- 10. Performselector在NSThread
- 11. performSelector在timeintervals
- 12. EXC_BAD_INSTRUCTION在performSelector
- 13. iOS的 - 在performselector
- 14. 后台任务或iphone
- 15. Iphone 4.0 - 后台计时器
- 16. iphone后台应用程序
- 17. 有关performSelector
- 18. iphone定时器倒计时在后台
- 19. iPhone应用程序在后台
- 20. 在后台请求iPhone的位置?
- 21. 在后台iPhone跟踪距离
- 22. 在后台播放音频(iPhone OS 4.0)
- 23. 如何在iPhone的后台运行sqlite?
- 24. iPhone停止在后台播放音频
- 25. DataMan iPhone App如何在后台工作
- 26. 在iPhone的后台发送邮件
- 27. iPhone iOS4-在后台播放闹钟?
- 28. 在后台上传iPhone图片
- 29. iPhone - 让收音机在后台运行
- 30. 在后台加载OpenGl视图。 iPhone
后台没有UI更新。 UI更改必须在主线程上执行。 – lukya 2012-03-20 09:12:31