我的iOS应用程序冻结但没有出现错误 [英] My iOS app freezes but no error appears

查看:111
本文介绍了我的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

这篇关于我的iOS应用程序冻结但没有出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆