我的iOS应用程序冻结但没有出现错误
是否有人知道我需要检查应用程序是否在一段时间后冻结?我的意思是,我可以在iPhone屏幕上看到该应用程序,但没有视图响应。
Does any body know what I need to check if app freezes after some time? I mean, I can see the app in the iPhone screen but no view responds.
我做了一些谷歌,我发现,我已经以某种方式阻止了主线程。
I did some google and i found that, i've blocked the main thread somehow.
但是我的问题是如何识别哪个方法导致主线程阻塞?有没有办法识别?
But my question is how to identify which method causes blocking of main thread? is there any way to identify?
一般来说,强烈建议在主线程上执行所有动画方法和界面操作,以及从服务器下载数据等后台任务......
Generally, it is highly recommended to perform on the main thread all animations method and interface manipulation, and to put in background tasks like download data from your server, etc...
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//here everything you want to perform in background
dispatch_async(dispatch_get_main_queue(), ^{
//call back to main queue to update user interface
});
});
资料来源: http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks