Low frame rate during UINavigationController push transition

后端 未结 2 1210
傲寒
傲寒 2021-01-15 02:31

I have a UINavigationController, and push from the root view controller to the next view controller. This second view controller is fairly \"heavy\", in that it

相关标签:
2条回答
  • 2021-01-15 02:56

    After further testing, I was able to diagnose the problem. The second view involved includes many UIImageViews. Removing those views or hiding them fixes the problem.

    What threw me off was the fact that only the first portion of the animation suffered from frame rate issues, while the remainder of the animation was perfectly smooth (in the case of longer animations). This shows me that the device is quite capable of animating the transition smoothly, even with all the subviews present.

    I'm still not an expert on iOS compositing, but I'm guessing the various layers are being laid out and cached, leading to the slowdown. The workaround is to push to the view with most of the subviews hidden, then show them using another animation once the view is visible.

    0 讨论(0)
  • 2021-01-15 03:09

    I have not stumbled upon this with the navigation controller but I got much the same result when updating a table view from another thread, the UI was really slow to update at first but after a short delay everything was showing again. As Justin points out in a comment, you should do UI work on the main thread. A simple way to accomplish this is wrap your call to the UI in a GCD block:

    dispatch_sync(dispatch_get_main_queue(), ^{
    // Do UI stuff here
    });
    

    or use

    performSelectorOnMainThread:withObject:waitUntilDone:

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