iOS Program boot boot sample

Source: Internet
Author: User

Summary

This chapter describes the iOS development process during the first launch of the program boot example, the main use of the Uiscrollview as a guide interface, using the Nsuserdefaults phase key value to determine whether the program first start.


Main technical judgment whether first start

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {    Override point for customization after application launch.        Whether to start if for the first time    (![ [Nsuserdefaults Standarduserdefaults] boolforkey:@ "Firstlaunch"]    {        //Note set to True        [[Nsuserdefaults Standarduserdefaults] Setbool:yes forkey:@ "everlaunched"];        [[Nsuserdefaults Standarduserdefaults] setbool:yes forkey:@ "Firstlaunch"];                viewcontroller* Viewcontroller = [[Viewcontroller alloc] init];        Viewcontroller.firsttime = YES;        Self.window.rootViewController = Viewcontroller;    }    else    {        NSLog (@ "is not the first time to start");    }            return YES;}
Note here that the first successful after the value of the key value set to Yes, so that the next time will not be judged to Yes, many people on the web are not set, but I do not set it is always judged to be the first start, do not know what other people are.

At the same time, because the start page I put him as a sub-page in the program's main page, so here through the main Page controller properties to determine whether to display the boot page, here after the first start, the property firsttime set to Yes, then the program will display the boot page.


Show Boot page
-(void) viewdidload{[Super Viewdidload];        Additional setup after loading the view, typically from a nib. [Self initui];}        -(void) initui{//Start animation if (self.firsttime) {[Self showstartpage];    Self.firsttime = NO;        } else {self.view.backgroundColor = [uicolor Whitecolor];        uilabel* label = [[UILabel alloc] Initwithframe:cgrectmake (20, 200, 350, 40)];        Label.text = @ "Welcome to my application, we are in perfect ...";    [Self.view Addsubview:label];        }}-(void) showstartpage{nsinteger pagenumber = 3;    Scrolling page uiscrollview* scrollView = [[Uiscrollview alloc] initWithFrame:self.view.frame];    [ScrollView setcontentsize:cgsizemake (Scrollview.frame.size.width*pagenumber, 0)];    scrollview.pagingenabled = YES;    [Self.view Addsubview:scrollview];        _scrollview = ScrollView;    CGRect frame = self.view.frame;        Frame.origin.x-= Frame.size.width; for (Nsinteger i=0; i<pagenumber; i++) {frame.origin.x + = FramE.size.width;        uiimageview* ImageView = [[Uiimageview alloc] initwithframe:frame];        [ImageView setimage:[uiimage imagenamed:[nsstring stringwithformat:@ "%ld.jpg", i+1]];        [ImageView Setcontentmode:uiviewcontentmodescaleaspectfill];    [ScrollView Addsubview:imageview];    } cgfloat w = FRAME.SIZE.WIDTH/2;    CGFloat h = 40;    CGFloat x = frame.origin.x + (frame.size.width-w)/2;        CGFloat y = frame.origin.y+frame.size.height-60;    uibutton* Welcomebutton = [[UIButton alloc] Initwithframe:cgrectmake (x, Y, W, h)];    [Welcomebutton settitle:@ "go to see more wonderful" forstate:uicontrolstatenormal];        [ScrollView Addsubview:welcomebutton]; [Welcomebutton addtarget:self Action: @selector (onwelcome:) forcontrolevents:uicontroleventtouchupinside];}    -(void) Onwelcome: (ID) sender{for (uiview* view in [_scrollview Subviews]) {[View Removefromsuperview];        } [_scrollview Removefromsuperview]; [Self initui];}
When the outside is setFirsttimeWhen yes, the boot page is displayed, where three images are shown as a guide page and are managed using control Uiscrollview. At the same time the last page added a button, click the button to enter the main program interface.


Run results

iOS Program boot boot sample

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.