The point of this feature is how to tell if the application was first launched. Actually, it's simple.
We just need to write a user-guided page in a class that basically uses Uiscrollview ,
A new class that inherits from Uiviewcontroller is named Userguideviewcontroller ,
Write in userguideviewcontroller.m
1- (void) Viewdidload2 { 3[Super Viewdidload];4 //Do any additional setup after loading the view. 5Self.view.backgroundColor =[Uicolor Redcolor];6 7[Self initguide];//Load New User Guide page 8 } 9 Ten- (void) Initguide One { AUiscrollview *scrollview = [[Uiscrollview alloc] Initwithframe:cgrectmake (0,0, the,640)]; -[ScrollView Setcontentsize:cgsizemake ( the,0)]; -[ScrollView Setpagingenabled:yes];//View full page display the //[ScrollView Setbounces:no];//avoid bouncing, and avoid exposing the root view - -Uiimageview *imageview = [[Uiimageview alloc] Initwithframe:cgrectmake (0,0, the,460)]; -[ImageView setimage:[uiimage imagenamed:@"0.png"]]; +[ScrollView Addsubview:imageview]; -[ImageView release]; + AUiimageview *imageview1 = [[Uiimageview alloc] Initwithframe:cgrectmake ( the,0, the,460)]; at[Imageview1 setimage:[uiimage imagenamed:@"1.png"]]; -[ScrollView Addsubview:imageview1]; -[Imageview1 release]; - -Uiimageview *imageview2 = [[Uiimageview alloc] Initwithframe:cgrectmake (640,0, the,460)]; -[Imageview2 setimage:[uiimage imagenamed:@"2.png"]]; in[ScrollView addsubview:imageview2]; -[Imageview2 release]; to +Uiimageview *IMAGEVIEW3 = [[Uiimageview alloc] Initwithframe:cgrectmake (960,0, the,460)]; -[Imageview3 setimage:[uiimage imagenamed:@"3.png"]]; theimageview3.userinteractionenabled = YES;//Open IMAGEVIEW3 User interaction, otherwise the button below will not respond *[ScrollView addsubview:imageview3]; $[IMAGEVIEW3 release];Panax Notoginseng -UIButton *button = [UIButton buttonwithtype:uibuttontypecustom];//load a transparent button on the IMAGEVIEW3 the[button Settitle:nil forstate:uicontrolstatenormal]; +[Button Setframe:cgrectmake ( $,371, the,Panax Notoginseng)]; A[button addtarget:self action: @selector (firstpressed) forcontrolevents:uicontroleventtouchupinside]; the[imageview3 Addsubview:button]; + -[Self.view Addsubview:scrollview]; $[ScrollView release]; $}
Method of button
1 -(void) firstpressed2 {3 [self Presentmodalviewcontroller:[[[weiboviewcontroller alloc] init] autorelease] animated:yes]; // Click button to jump to the root view 4 }
As for adding a button because my user booted the last page has a picture button, which says start using I add a transparent button above to implement the Calling method
Open appdelegate.m
First introduce the header file
1 " UserGuideViewController.h " 2 " WeiBoViewController.h "
Weiboviewcontroller is my root view.
Application: DIDFINISHL aunchingwithoptions: Judging within the method
1-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) Launchoptions2 { 3Self.window =[[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease];4 //Override point for customization after application launch. 5 6 //Judging is not the first time to launch the app 7 if(! [[Nsuserdefaults Standarduserdefaults] Boolforkey:@"Firstlaunch"]) 8 { 9[[Nsuserdefaults Standarduserdefaults] Setbool:yes forkey:@"Firstlaunch"];TenNSLog (@"first time start"); One //If this is the first time, use Userguideviewcontroller (User Guide page) as the root view AUserguideviewcontroller *userguideviewcontroller =[[Userguideviewcontroller alloc] init]; -Self.window.rootViewController =Userguideviewcontroller; -[Userguideviewcontroller release]; the } - Else - { -NSLog (@"not the first time ."); + //use Loginviewcontroller as the root view if it is not the first time you start -Weiboviewcontroller *weiboviewcontroller =[[Weiboviewcontroller alloc] init]; +Self.window.rootViewController =Weiboviewcontroller; A[Weiboviewcontroller release]; at - } - -Self.window.backgroundColor =[Uicolor Whitecolor]; -[Self.window makekeyandvisible]; - returnYES; in}
This allows the app to be opened for the first time to display user boot and no longer display
iOS Development app first boot display user boot