13

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?

4

2 回答 2

2

几周前我有一个类似的问题,我写了一篇关于我发现的博客文章:

http://bradbambara.wordpress.com/2014/07/31/object-life-cycle-uiviewcontroller/

TL;DR 版本是 iOS 将:

  • 执行新场景的布局
  • 执行到新场景的过渡(如果是动画过渡)

...所以我的猜测是延迟可能是由特别长的过渡引起的,或者如果您在布局代码中执行任何性能密集型工作。

于 2014-09-17T21:04:45.490 回答
1

转换本身(我相信)应该只需要 0.3 秒。剩下的可能是什么?

资源通常通过以下方式消耗:drawRect:, layoutSubviews, viewDidLoad, viewWillAppear:. 此外,从 NIB 加载可能需要相当长的时间。

之后viewWillAppear:,iOS 将对新的(可能是当前的)视图进行快照,以在两个屏幕之间执行流畅的动画。因此,请确保两个控制器视图的绘图和布局代码足够快。

于 2012-10-20T18:59:30.997 回答