How to add a boot page when iOS starts small demo

Source: Internet
Author: User

I believe everyone has seen the mobile phone application in the launch, there will be a very beautiful page, in this page after the display, if you are the first to open the app will also have a hint picture (such as how to use the program and so on), today I wrote a small demo here to share, you can give new scholars a reference

The above is how to find the location of the Settings Guide page in Xcode

For the picture settings you can see the figure there are 2x and R4 two kinds, for these two types of differences are as follows


R4 represents the Retina screen is also high-definition screen, then here we choose the Guide picture, in general, in the project if there is [email protected] or default.png or [email protected], Such a picture, then this image will be set by default to our program's Guide picture, then these three kinds of pictures of the difference is as follows

    1. Default.png is suitable for a normal screen of an iphone like IPhone4 before
    2. [Email protected] is adapted to the retina screen of the iphone4s
    3. [email protected] adaptation is IPhone5 5c 5s
for IPhone6 's boot page picture format, I don't know yet (if you know it can be added OH)
The above is set in Xcode, then like the beginning of the article, each time we start the program in addition to guide the page image and how to use the program's page or other, and then enter the main interface, then if so What should I do with this fake boot page (my own name)? show it through my own little demo.

idea: Like the above page we all know that only the application will appear when the first open, so I use the local sandbox to create a file, the first time I entered, the sandbox is not the file, so the program entered the false boot page, and then into the main program, Immediately after the creation of this file, and so I am the second time to start the program when I judge the sandbox there is no this file, if so I directly into the main page, so that I can achieve the desired effect
 
//this is written directly in Appdelegate-    (BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{    Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];    Override point for customization after application launch.       Self.window.backgroundColor = [Uicolor Whitecolor];    Isout =no;        Make a file in the sandbox and judge if the sandbox has no this file Nsfilemanager *manager=[nsfilemanager Defaultmanager];        BOOL Ishasfile=[manager fileexistsatpath:[nshomedirectory () stringbyappendingstring:@ "Aa.txt"];     if (ishasfile) {[self gotomain];//To True indicates that a file has been entered on the home page}else{[i makelaunchview];//false means no files, no pages}        [Self.window makekeyandvisible]; return YES;} 
Fake boot page-(void) makelaunchview{Nsarray *arr=[nsarray arraywithobjects:@ "Helpphoto_one.png", @ "Helpphoto_two.png", @ " Helpphoto_three.png ", @" Helpphoto_four.png ", @" Helpphoto_five.png ", the nil];//array is what I want to display the fake boot page picture//through ScrollView    Add these images to the top to scroll these pictures uiscrollview *scr=[[uiscrollview alloc] initWithFrame:self.window.bounds];    Scr.contentsize=cgsizemake (320*arr.count, self.window.frame.size.height);    Scr.pagingenabled=yes;    scr.tag=7000;    scr.delegate=self;    [Self.window ADDSUBVIEW:SCR]; for (int i=0; i<arr.count; i++) {uiimageview *img=[[uiimageview alloc] Initwithframe:cgrectmake (i*320, 0, 320,        Self.window.frame.size.height)];        Img.image=[uiimage Imagenamed:arr[i]];        [SCR addsubview:img];    [img Release]; }} #pragma the agent for Mark ScrollView-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{//This is where I scroll to determine which picture I'm scrolling to, If you scroll to the last picture, then//if it is sliding down to the main interface, I use the offset to judge, when//altogether five pictures, so when the picture all slipped and then like after more than 30 slide after the next action if (Scrollview.con TentoffsET.X&GT;4*320+30) {isout=yes;//This is a global variable I declare, bool type, with an initial value of no, change the value to YES}}//stop sliding-(void) SCR when the condition I want is reached      Ollviewdidenddecelerating: (Uiscrollview *) scrollview{//Judge Isout is really going to go into the main interface if (isout) {//Added here an animation, (according to personal preferences) [UIView animatewithduration:1.5 animations:^{scrollview.alpha=0;//let ScrollView fade away}completio     n:^ (BOOL finished) {[ScrollView removefromsuperview];//remove ScrollView [self gotomain];//into the main interface}];   }}//go home-(void) gotomain{//If the first entry does not have a file, we will create this file Nsfilemanager *manager=[nsfilemanager Defaultmanager]; Determine if I created the file, create the file if not created (this will run once, that is, the first time you start the program) if (![ Manager fileexistsatpath:[nshomedirectory () stringbyappendingstring:@ "Aa.txt"]) {[Manager Createfileatpath:[nshom   EDirectory () stringbyappendingstring:@ "Aa.txt"] contents:nil Attributes:nil]; }    }

In this home page
-(void) Gotomain method I wrote only how to create this file, as for the others to be written according to your application situation,


as the picture above is the first picture of my fake boot page


How to add a boot page when iOS starts small demo

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.