b2cloud

13th November 2014

Presenting UIViewController on launch in iOS 8

Guides | Reviews By 2 years ago

When you show a login screen or a walkthrough in your app, a common strategy is to present a view controller with no animation in your application:didFinishLaunchingWithOptions: method.

In iOS 8 this has caused some issues because the window’s root view controller can be seen for a split second before your presented view controller is seen, this is an Apple bug.

For the mean time, I have found a pretty easy hack that can be used to fix this:

UIViewController *viewController = [[UIViewController alloc] init];
[viewController.view setBackgroundColor:[UIColor greenColor]];

//  Temporary iOS8 fix for 'presentation lag' on launch
[self.window addSubview:viewController.view];

[self.window.rootViewController presentViewController:viewController animated:NO completion:nil];

How this works is that just before you present your view controller, you add it to the window hierarchy. Apple’s split second bug still occurs, but because the presented view controller is already part of the window it looks seamless.

  • Francisco Ochoa

    Hi ! thanks for sharing I have a question the UIViecontroller of the above example is the login controller?, or Home ViewController, thanks,

  • pilot34

    nice trick, thx!

Recommended Posts

Opening the Settings app programmatically in iOS 8

Post by 2 years ago

When iOS 7 first launched developers found the hidden URL schemes used by Apple to open the Settings app from another app. Developers started using this hidden URL in their apps. Apple realized and took

Got an idea?

We help entrepreneurs, organizations and established brands from around
the country bring ideas to life. We would love to hear from you!