iOS Development: How can I preload a view controller before pushing it onto the navigation stack?

There is a side effect with just using [viewController loadView] and that is that viewDidLoad will not be called automatically after the view has loaded.

To do it properly and to make sure that viewDidLoad gets called, instead of calling loadView yourself you can instantiate the UIViewController´s view using

  UIView *view = myViewController.view;

or

  UIView *view = [myViewController view];

This will both call loadView (if the view was not already loaded) and then viewDidLoad when the view has finished loading.


In response to the accepted answer, you must not call -loadView manually. From the documentation:

You should never call this method directly. The view controller calls this method when its view property is requested but is currently nil. This method loads or creates a view and assigns it to the view property.

Instead you should just call [myViewController view] which will trigger the view to load.

As always, read the documentation!


Put this on your delegate's application:didFinishLaunchingWithOptions:

  dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
                   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:[NSBundle mainBundle]];
                   [storyboard instantiateViewControllerWithIdentifier: @"TheViewControllerYouWantToPreload"];
                 });

The dispatch_async will make the whole thing load in background.