Reputation: 26526
I am optimizing a transition that seems to be slow on my device. I am pushing one UIViewController
from another when a UITableView
's row is selected. There is a noticeable pause after row selection and before the new view is pushed.
Some logging indicates that all of my code is reasonably quick, from row selection until the pushed controller's viewWillAppear
. But then the time between viewWillAppear
and viewDidAppear
is logged at around 0.7 seconds.
The transition itself (I believe) should only take 0.3 seconds. What could be accounting for the remainder?
I am testing on an iPhone 4, so I'm not expecting the snappiest performance. But I should be able to match the same performance of other similar apps on the same device, no?
Upvotes: 13
Views: 4301
Reputation: 509
I had a similar question a few weeks ago, and I wrote a blog post about what I found:
http://bradbambara.wordpress.com/2014/07/31/object-life-cycle-uiviewcontroller/
The TL;DR version is that iOS will:
...so my guess is the delay could be caused by an especially long transition, or if you're doing any performance-intensive work in your layout code.
Upvotes: 2
Reputation: 9493
The transition itself (I believe) should only take 0.3 seconds. What could be accounting for the remainder?
Resources are usually consumed in the following methods: drawRect:
, layoutSubviews
, viewDidLoad
, viewWillAppear:
. Also, loading from NIB may require quite much time.
After viewWillAppear:
, iOS will make a snapshot of the new (and probably current) view to perform smooth animation between two screens. So make sure that drawing and layout code for both controller views is fast enough.
Upvotes: 1