iOS boot page Toggle 4 Pictures Last one stop three seconds go to homepage

Source: Internet
Author: User

//

Viewcontroller.m

LIBAOZHENG0826

//

Created by Zhang Yanfeng on 15/8/26.

Copyright (c) 2015 Zhang Yanfeng. All rights reserved.

//

#import "ViewController.h"

@interface Viewcontroller ()

{

BOOL isout;

}

@end

@implementation Viewcontroller

-(void) Viewdidload {

[Super Viewdidload];

if (![ [Nsuserdefaults Standarduserdefaults] boolforkey:@ "Firstlanch"]) {

NSLog (@ "program first install start");

[[Nsuserdefaults Standarduserdefaults] setbool:yes forkey:@ "Firstlanch"];

[Self makelaunchview];

}

else{

NSLog (@ "program is not the first install start");

}

}

-(void) makelaunchview{

Zhang Yanfeng, Guide page, "Four photos"

Uiscrollview *myscrollview=[[uiscrollview Alloc]initwithframe:cgrectmake (0,0,568, 320)];//display box size

myscrollview.tag=121;

Myscrollview.backgroundcolor=[uicolor Redcolor];

Myscrollview.contentsize=cgsizemake (568*4, 320);//Valid display area

myscrollview.delegate=self;//adding agents

Add a picture Group

for (int i=0; i<4; i++) {

Uiimageview *imageview1=[[uiimageview alloc]initwithframe:cgrectmake (568*i, 0, 568, 320)];//set picture display size

NSString *imagename=[nsstring stringwithformat:@ "%d.jpg", I];

Imageview1.image=[uiimage Imagenamed:imagename];

[Myscrollview Addsubview:imageview1];

}

myscrollview.pagingenabled=yes;//by Page

[Self.view Addsubview:myscrollview];

}

-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{

This is when scrolling to determine which picture I scroll to, if you scroll to the last picture, then

If you swipe down, it's time to go to the main interface, and I'm using offsets to determine when

A total of five pictures, so when the pictures are all slipped and like after the slide more than 30 time to do the next action

if (scrollview.contentoffset.x>4*320+30) {

isout=yes;//This is a global variable that I declare. type bool, with an initial value of no, change the value to YES when the condition I want is reached

}

}

Stop sliding

-(void) scrollviewdidenddecelerating: (Uiscrollview *) scrollview{

Judging Isout is really going to go into the main interface.

if (isout) {

An animation has been added here (according to your preference)

[UIView animatewithduration:1.5 animations:^{

scrollview.alpha=0;//Let ScrollView fade away

}completion:^ (BOOL finished) {

[ScrollView removefromsuperview];//to remove ScrollView

[Self gotomain];//into the main interface

} ];

}

}

-(void) didreceivememorywarning {

[Super didreceivememorywarning];

Dispose of any resources the can be recreated.

}

@end

iOS boot page Toggle 4 Pictures Last one stop three seconds go to homepage

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.