My iOS app freezes but no error appears

后端 未结 5 1672
时光取名叫无心
时光取名叫无心 2021-02-03 13:43

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 fou

相关标签:
5条回答
  • 2021-02-03 13:47

    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.

    0 讨论(0)
  • 2021-02-03 13:47

    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.

    0 讨论(0)
  • 2021-02-03 13:50

    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

    0 讨论(0)
  • 2021-02-03 13:50

    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.

    0 讨论(0)
  • 2021-02-03 13:54

    Most Of the Time this happened to me when a design change is being called for INFINITE time. Which function can do that? well it is this one:

    override func viewDidLayoutSubviews() {
            super.viewDidLayoutSubviews()
        }
    

    Solution is to add condition where the function inside of viewDidLayoutSubviews get calls only 1 time.

    0 讨论(0)
提交回复
热议问题