Slow UIViewController load time (slow ClientState warning)

Since I converted an old app to iOS 6 I've started getting the following message in my console.

WARNING: Slow defaults access for key ClientState took 0.023656 seconds, tolerance is 0.020000

Other than updating my code from iOS 5 to iOS 6, I also switched over to auto-layout. I've run Instruments/Time Profiler and the rootViewController in my appDelegate is the problem. Everytime I switch view controllers it sucks the vast major of the time, (regardless of whether I have to instantiate the view controller or re-using one which already exists).

window.rootViewController = myViewController;

I know what the method does superficially, but I'm not sure what happens under the covers... what would cause it to be slow now and what can I do to speed it up?

EDIT: I've tried taking my storyboard off auto-layout and the problem vanishes (of course my UI layout is in shambles). So the obvious conclusion is, it's something about auto-layout. I've probably just under 70 views all combined on the screen and the various constraints needed to lay them out. I have a hard time believing auto-layout is that much slower (from ~80ms with auto-layout turned off to ~1370ms with auto- layout turned on).


Having 70 views on-screen sounds like a lot! My proposal is to make it simpler in some way:

  • Do you REALLY need all 70 views at the same time?

  • Check if all views need autolayout, remove it where-ever possible

  • Can some views be replaced by graphics? I've used views eg for shadows, might have been images
  • Can you split storyBoard into several smaller ones eg one for login, details, edit mode etc. Part of the slowness might come from system having to deal with (too) big storyBoards.


    Consider creating a new project with 2 view controllers and test the switching speed. Every iOS app has a window, a root view controller and a view controller. The problem isn't likely to be as narrow and clear-cut as you may be hoping. What does each view controller load? Did you inspect the underlying code? Does app delegate do anything on initialization or change of root view controller?

    链接地址: http://www.djcxy.com/p/11708.html

    上一篇: 用多个排序构建表达式

    下一篇: 缓慢UIViewController加载时间(慢ClientState警告)