ios - Change Initial View Controller for First Launch -
I know this question has been asked, but the methods are not working for me. I have a visual controller in which Includes a tutorial which I want to display as an initial scene for the first time when I open the app. After that, the main menu will always be the initial scene. The Storyboard ID "Tutorial" for my tutorial screen has the following code to find the first launch, but I did not know how to show the tutorial:
- (zero) ViewDidload {if ([[NSUserDefaults standardUserDefaults] boolForKey: @ "First launch"] {} Other {[NSUserDefaults Standard User Defaults] Setbool: Yes for Y: @ "First Launch"]; [[NSUserDefaults Standard User Defaults] Synchronize];
You can change the initial controller in two ways:
- Check the 'Initial VC' checkbox in the interface builder or
- configure it -Application: The Finnish Launching Destination: Method
Change the initial view controller by using the application
In-app: In-application: done Finnish Launching Destination: Your App Rep Legit.m) To check if the tutorial is required:
- (BOOL) Application: (UIApplication *) Application FinishLaunchingWithOptions: (NSDictionary *) LaunchOptions {// application Override point for optimization after launch (! [[NSUserDefaults standard user default] boolForKey: @ "First launch"]] {[NSUserDefaults Standard User Defaults] Setbool: Yes for Y: @ "First Launch"]; [[NSUserDefaults Standard User Defaults] Synchronize]; / *** Load vc *** Return yes; } To set the initial controller, you have to start the window property, create a VC and set it as root:
// 1. Start Window Style Window = [[UIWindow alloc] initWithFrame: UIScreen.mainScreen.bounds]; // 2. Get Storyboard UIStoryboard * Storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: zero]; // 3. Create VC Tutorial View Controller * Tutorial ViewController = [Storyboard Instant ViewerRelver Identifier: NSStringFromClass ([Tutorial ViewController Class])]; // 4. Set the root as its own. Window.rootViewController = tutorialViewController; // 5. Call to show ideas [self Windows and knowledgeable]; Hope it helps!
Comments
Post a Comment