presentViewController in AppDelegate with delay in iOS8

Tiago Almeida picture Tiago Almeida · Sep 15, 2014 · Viewed 14.2k times · Source

So I had a full working solution in iOS7 that displays a LoginViewController via presentViewController in the AppDelegate's didFinishLaunching.

Basically I am doing something like this:

UIViewController *backgroundViewController = ...
self.window.rootViewController = backgroundViewController;
[self.window makeKeyAndVisible];

[self.window.rootViewController presentViewController:loginViewController
                                             animated:NO ...]

In iOS8 I see a jump. First I see the backgroundViewController then after about 1 second or so the login appears.

So, how can I prevent this jump in iOS8?

I am seeing that are a ton of developers with this kind of problem but still didn't find a solution.

Answer

SomeGuy picture SomeGuy · Oct 11, 2014

Also a hack (for now), but just one line of code

Add the view of the view controller you're presenting to the window before presentation

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];

If you are presenting a navigation controller than add the navigation controller's view instead of its top view controller.