Join the User Guide page when using StoryBoard

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.