//
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