My iOS app freezes but no error appears

谁说胖子不能爱 提交于 2019-12-03 03:50:46

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
    });
});

Source : http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks

Launch your app and wait for it to freeze. Then press the "pause" button in Xcode. The left pane should show you what method is currently running.

Set a break point from where the freeze occurs and find which line cause that.

Chances may be,Loading of large data,disable the controls,overload in main thread,Just find out where that occurs using breakpoints and rectify based on that.

I reached an error similar to this, but it was for different reasons. I had a button that performed a segue to another ViewController that contained a TableView, but it looked like the application froze whenever the segue was performed.

My issue was that I was infinitely calling reloadData() due to a couple of didSet observers in one of my variables. Once I relocated this call elsewhere, the issue was fixed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!