It's a perfect move if you want to have an app with a boot page.
However, there are always some problems
(Don't forget to add the header file of the user boot page to the Apdelegate and the first page of the program when it starts)
Case One: Pure code
Decide whether to start the application for the first time
1-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) Launchoptions2 {3Self.window =[[UIWindow alloc]initwithframe:[[uiscreen mainscreen] bounds];4 if(! [[Nsuserdefaults Standarduserdefaults] Boolforkey:@"Firstlaunch"])5 {6[[Nsuserdefaults Standarduserdefaults] Setbool:yes forkey:@"Firstlaunch"];7NSLog (@"first time start");8 //If this is the first time, use Userguideviewcontroller (User Guide page) as the root view9Userguideviewcontroller *userguideviewcontroller =[[Userguideviewcontroller alloc] init];TenSelf.window.rootViewController =Userguideviewcontroller; One } A Else - { -NSLog (@"not the first time ."); theTranslatecontroller *TRANVC =[[Translatecontroller alloc] init]; -Self.window.rootViewController =TRANVC; - } -Self.window.backgroundColor =[Uicolor Whitecolor]; + [Self.window makekeyandvisible]; - returnYES; +}
Scenario Two: Using Storyboard
The situation is basically the same, the difference is
1 NSLog (@ " is not the first time to start "); 2 Uistoryboard *story = [Uistoryboard storyboardwithname:@ "mainstoryboard" Bundle: NIL]; 3 Uiviewcontroller * VC = [Story instantiateviewcontrollerwithidentifier:@ "translatecontroller " ]; 4 Self.window.rootViewController = VC;
Explain the principle first, if the use of pure code, it is not the first time to start the application will automatically execute the following code, so there is no problem
If you use storyboard, initialize the first view controller (the first interface of the program), nothing, (unless you add the control yourself), and storyboard does not start here when it starts, Instead, the default storyboard is the first view controller, so add a flag.
So that it can find the interface that should be started.
Join the User Guide page when using StoryBoard