UIViewController - mysteriously slow to load

2019-02-17 12:32发布

问题:

I'm writing a tab-based universal app where one of the tabs takes considerably much longer to load than the rest (approximately 5s), and it locks down the main thread while doing it.

Now, this specific tab is an image gallery, so it could be expected to take a little while to load and display the images, however, the delay occurs before I instantiate any of my variables... (The image loading is done on a separate thread anyway...)

I create my subviews etc. in the viewDidLoad method, but the delay occurs somewhere after the init method and before the viewDidLoad method.

(The delay is present even if I comment out everything in the viewDidLoad method.)

The View Controller is initialized with a nib containing nothing but a UIScrollView and a UIImagePickerController...

Does anyone know what's being loaded/processed before the viewDidLoad method?

回答1:

This is a problem with loading UIImagePickerController on the phone while being attached to the xcode harness. This creates a longer than normal delay. Try testing on the device without being connected to the xcode debugger.

link to similar post: http://www.iphonedevsdk.com/forum/iphone-sdk-development/4727-uiimagepickercontroller-slow-appear.html