How to make faster pushing a UIViewController into a UINavigationController
I have a multiple view based application, the problem is that whe开发者_开发知识库n I push one UIViewController the device (only when I test it on a real device) freezes for a second or two, I don't know why is this happening since the pushed UIViewController has only one UITextField & a button. This only happens when the view is pushed the first time, after this pushing the view is smooth.
Any ideas on how to avoid this?
Seems like you have something heavy on leaving the original view controller.
Can you post the exact code (the entire method around the push) of pushing the controller?
Are there any objects you can instantiate that are separate from the view controller you're pushing, which you can instantiate earlier? "Pre-loading" objects will help give the appearance of a faster view controller push.
You should definitely use Instruments to find out what's happening at the time when you first push that controller.
Use the Intrument's CPU sampler tool and start a recording. Then do whatever you need to do in your app to push the controller. You will probably see a spike in the CPU-load chart. You can investigate stack traces at this point to find out what's happening and why that takes so long.
精彩评论