I'd like to present modally, at first startup, a tutorial wizard to the user.
Is there a way to present a modal UIViewController
on application startup, without seeing, at least for a millisecond, the rootViewController
behind it?
Now I'm doing something like this (omitting first-launch checks for clarity):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
UIStoryboard *storyboard = self.window.rootViewController.storyboard;
TutorialViewController* tutorialViewController = [storyboard instantiateViewControllerWithIdentifier:@"tutorial"];
tutorialViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.window makeKeyAndVisible];
[self.window.rootViewController presentViewController:tutorialViewController animated:NO completion:NULL];
}
with no luck. I've tried to move [self.window makeKeyAndVisible];
to before the [... presentViewController:tutorialViewController ...]
statement, but then the modal doesn't even appear.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…