iOS boot page

Source: Internet
Author: User

I'm here, yes. The Guide page is Viewcontroller

#import <UIKit/UIKit.h>

I'm here to add the picture to a bundle file.
#define GET_IMAGE_FROM_BUNDLE_PATH (imagename,bundlename) [Resbundleutils imagenamedfromimagesbundlepng:imagename Withsubpath:bundlename]

Suitable for 3.5 inch screen and 4 inch picture name
#define ADAPT_IMAGE_NAME (ImageName) (is_iphone_568?) [NSString stringwithformat:@ "%@-568h", [ImageName Stringbydeletingpathextension]]:imagename)


@protocol useguidedelegate <NSObject>

-(void) Removeguideview;

@end

@interface Useguideviewcontroller:uiviewcontroller
{
int currentpage;
Uipagecontrol *pagecontrol;
Uiimageview *guideview;
}
@property (assign,nonatomic) id<useguidedelegate> delegate;

@end

Implementation file



#import "UseGuideViewController.h"


@interface Useguideviewcontroller () <UIScrollViewDelegate>

@end

@implementation Useguideviewcontroller

-(ID) Initwithnibname: (NSString *) Nibnameornil Bundle: (NSBundle *) Nibbundleornil
{
self = [super Initwithnibname:nibnameornil Bundle:nibbundleornil];
if (self) {
[Self initwithguideview];
}
return self;
}

-(void) viewdidload
{
[Super Viewdidload];

}
/**
* ScrollView
*/
-(void) Initwithguideview
{
Uiscrollview * scroll = [[Uiscrollview alloc] Initwithframe:cgrectmake (0,0,self.view.frame.size.width, Self.view.frame.size.height)];

Scroll.showshorizontalscrollindicator = NO;
Scroll.showsverticalscrollindicator = NO;
Scroll.backgroundcolor=[uicolor Clearcolor];
Scroll.bounces = NO;
scroll.delegate=self;
scroll.pagingenabled = YES;
scroll.scrollenabled = YES;
scroll.directionallockenabled = YES;

for (int i=0;i<4;i++)
{
Guideview = [[Uiimageview alloc] Initwithframe:cgrectmake (screen_width*i,0, +, self.view.frame.size.height)];
Guideview.tag = i+1;
if (i==0)
NSString *imgname = [NSString stringwithformat:@ "bg_intro%d", i+1];
UIImage *img= Get_image_from_bundle_path (Adapt_image_name (imgname), @ "Userguideimage");
Guideview.image = img;
Guideview.userinteractionenabled=yes;
[Scroll Addsubview:guideview];
Scroll.contentsize = Cgsizemake (screen_width* (i+1), 0);
if (guideview.tag==4)
{
UITapGestureRecognizer *tapgr=[[uitapgesturerecognizer alloc]initwithtarget:self Action: @selector (TouchDown)];
[Guideview ADDGESTURERECOGNIZER:TAPGR];
}
}

[Self.view Addsubview:scroll];
Pagecontrol=[[uipagecontrol Alloc]initwithframe:cgrectmake (0,screen_height-50, SCREEN_WIDTH, 21)];
Pagecontrol.backgroundcolor=[uicolor Clearcolor];
pagecontrol.numberofpages=4;
pagecontrol.currentpage=0;
[Self.view Addsubview:pagecontrol];

}
/**
* Pagecontrol
*
* @param scrollView ScrollView
*/
-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView
{
CGFloat pagewidth = self.view.frame.size.width;
int page = Floor ((SCROLLVIEW.CONTENTOFFSET.X-PAGEWIDTH/2)/pagewidth) + 1;
pagecontrol.currentpage = page;

}
/**
* Gesture Method
*/
-(void) TouchDown
{
if ([Self.delegate respondstoselector: @selector (Removeguideview)])
{
[Self.delegate Removeguideview];
}
}
-(void) didreceivememorywarning
{
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}

@end

And then in the place of the call:

#pragma mark-Show Guide page

if (![ [Nsuserdefaults Standarduserdefaults] boolforkey:@ "YES"])
{
[Self showguideview];
}
Else

{

Todo

}

-(void) Showguideview
{
[[Nsuserdefaults Standarduserdefaults] setbool:yes forkey:@ "YES"];
Useguideviewcontroller *guideview = [[Useguideviewcontroller alloc]init];
Guideview.delegate = self;
}

#pragma mark--Guide Map Agent
-(void) Removeguideview
{

Todo

}

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.