打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
如何制作用户引导界面
      刚使用软件时,推出用户使用引导界面,再进入选项栏控制器。
-(BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

   self.window= [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

   // Override point for customization afterapplication launch.

   //增加标识,用于判断是否是第一次启动应用...

   if(![[NSUserDefaultsstandardUserDefaults]boolForKey:@"everLaunched"]) { 

       [[NSUserDefaultsstandardUserDefaults]setBool:YES forKey:@"everLaunched"]; 

       [[NSUserDefaultsstandardUserDefaults]setBool:YES forKey:@"firstLaunch"]; 

    }

    

    

    

   if([[NSUserDefaultsstandardUserDefaults]boolForKey:@"firstLaunch"]) {

       tipViewController *appStartController =[[tipViewControlleralloc] init];

    self.window.rootViewController=appStartController;

       [appStartController release];

    }else {

       NextViewController *mainViewController =[[NextViewControlleralloc] init];

       self.window.rootViewController=mainViewController;

       [mainViewController release];

       

    }

   self.window.backgroundColor = [UIColor whiteColor];

   [self.windowmakeKeyAndVisible];

   return YES;

}


在根视图1中

 

#import

#import"UIImage+SplitImageIntoTwoParts.h"


@interface tipViewController :UIViewController<</span>UIScrollViewDelegate>


@property (nonatomic,strong)UIImageView *imageView;

@property (nonatomic,strong)UIImageView *left;

@property (nonatomic,strong)UIImageView *right;


@property (retain, nonatomic) UIScrollView *pageScroll;

@property (retain, nonatomic) UIPageControl *pageControl;


-(void)gotoMainView:(id)sender;

@property (retain, nonatomic) UIButton *gotoMainViewBtn;


@end


 

#import"tipViewController.h"

#import"NextViewController.h"

#import "AppDelegate.h"

#define HEIGHT 460


@interface tipViewController()


@end


@implementationtipViewController

@synthesize gotoMainViewBtn =_gotoMainViewBtn;


@synthesize imageView;

@synthesize left = _left;

@synthesize right =_right;

@synthesize pageScroll;

@synthesize pageControl;


-(id)initWithNibName:(NSString *)nibNameOrNilbundle:(NSBundle*)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

       // Custominitialization

    }

   return self;

}


-(void)viewDidLoad

{

   [superviewDidLoad];

// Do any additional setup after loading the view.


    

   self.view.backgroundColor=[UIColor grayColor];

   pageScroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0, 320,HEIGHT)];

    pageScroll.contentSize=CGSizeMake(5*320,HEIGHT);

   pageScroll.pagingEnabled=YES;

   pageScroll.delegate=self;

    

   self.gotoMainViewBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    self.gotoMainViewBtn.frame = CGRectMake(110, 200, 80, 30);

   [self.gotoMainViewBtn setTitle:@"进入主界面"forState:UIControlStateNormal];

   [self.gotoMainViewBtn addTarget:selfaction:@selector(gotoMainView:)forControlEvents:UIControlEventTouchUpInside];

    

    self.imageView = [[UIImageView alloc]init];

    self.imageView.frame = CGRectMake(0, 0,320, 480);

    self.imageView.image = [UIImage imageNamed:@"test6.jpg"];

    

    UIImageView *imageView1 = [[UIImageView alloc]init];

//    imageView1.frame =CGRectMake(0, 0, 320, 480);

    imageView1.image = [UIImage imageNamed:@"1.jpg"];

    

    UIImageView *imageView2 = [[UIImageView alloc]init];

//    imageView2.frame =CGRectMake(320, 0, 320, 480);

    imageView2.image = [UIImage imageNamed:@"2.jpg"];

    

    UIImageView *imageView3 = [[UIImageView alloc]init];

//    imageView3.frame =CGRectMake(2*320, 0, 320, 480);

    imageView3.image = [UIImage imageNamed:@"3.jpg"];

    

    UIImageView *imageView4 = [[UIImageView alloc]init];

//    imageView4.frame =CGRectMake(3*320, 0, 320, 480);

    imageView4.image = [UIImage imageNamed:@"4.jpg"];

    

    UIView *returnView = [[UIView alloc]init];

    returnView.backgroundColor = [UIColor redColor];

//    returnView.frame =CGRectMake(4*320, 0, 320, 480);

    [returnView addSubview:self.imageView];

    [returnView addSubview:self.gotoMainViewBtn];

//    [pageScrolladdSubview:returnView];

    

    for (int i=0; i<<span style="color:#3619d9">5; i++) {

       if(i==0) {

          [pageScroll addSubview:imageView1];

          imageView1.frame = CGRectMake(i*320, 0,320, HEIGHT);

       }elseif (i==1) {

          [pageScroll addSubview:imageView2];

          imageView2.frame = CGRectMake(i*320, 0,320, HEIGHT);

       }elseif(i==2){

          [pageScroll addSubview:imageView3];

          imageView3.frame = CGRectMake(i*320, 0,320, HEIGHT);

       }elseif(i==3){

          [pageScroll addSubview:imageView4];

          imageView4.frame = CGRectMake(i*320, 0,320, HEIGHT);

       }elseif(i==4){

          returnView.frame = CGRectMake(i*320, 0,320, HEIGHT);

          [pageScroll addSubview:returnView];

       }

    }

    

    [self.view addSubview:pageScroll];

    

   pageControl=[[UIPageControl alloc]init];

    pageControl.frame=CGRectMake(141,364,50,50);

   [pageControlsetNumberOfPages:5];

   pageControl.currentPage=0;

   [pageControladdTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];

   [self.viewaddSubview:pageControl];

    

   [self.viewaddSubview:pageControl];

}


-(void)viewDidUnload

{

   [superviewDidUnload];

   // Release any retained subviews of themain view.

}


-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return (interfaceOrientation ==UIInterfaceOrientationPortrait);

}


-(void)animationDidStop:(NSString *)animationIDfinished:(NSNumber *)finishedcontext:(void *)context

{

    if ([animationID isEqualToString:@"split"] && finished) {

       

       [self.leftremoveFromSuperview];

       [self.rightremoveFromSuperview];

//       NextViewController *controller =[[NextViewController alloc] init];

//       [self presentModalViewController:controlleranimated:YES];

//       [controller release];

       NSLog(@"==========succeed");

       [pageScroll removeFromSuperview];

       AppDelegate*app = [[AppDelegatealloc]init];

       [app shardView];

       

       

    }  

}


-(void)gotoMainView:(id)sender{

    

   [[NSUserDefaultsstandardUserDefaults]setBool:NO forKey:@"firstLaunch"];

   [self.gotoMainViewBtn setHidden:YES];

   NSArray *array= [UIImagesplitImageIntoTwoParts:self.imageView.image];

   self.left= [[UIImageView alloc] initWithImage:[array objectAtIndex:0]];

   self.right= [[UIImageView alloc] initWithImage:[array objectAtIndex:1]];

    [self.view addSubview:self.left];

    [self.view addSubview:self.right];

    [self.pageScroll setHidden:YES];

   [self.pageControl setHidden:YES];

   self.left.transform = CGAffineTransformIdentity;

   self.right.transform = CGAffineTransformIdentity;

    

   [UIViewbeginAnimations:@"split" context:nil];

   [UIViewsetAnimationDelegate:self];

   [UIViewsetAnimationDuration:1];

    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

    

   self.left.transform =CGAffineTransformMakeTranslation(-160,0);

   self.right.transform =CGAffineTransformMakeTranslation(160,0);   

   [UIViewcommitAnimations];

    

}


-(void)scrollViewDidScroll:(UIScrollView *)scrollView

{

    CGPoint offset=scrollView.contentOffset;

    pageControl.currentPage=offset.x/320.0f;

   pageControl.hidden= NO;

   //   NSLog(@"%d",pageControl.currentPage);

}

-(void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView{

    CGPoint offset=scrollView.contentOffset;

    pageControl.currentPage=offset.x/320.0f;

   pageControl.hidden= YES;

}

-(void)pageTurn:(UIPageControl *)aPageControl

{

    int whichPage=aPageControl.currentPage;

   [UIViewbeginAnimations:nil context:NULL];

   [UIViewsetAnimationDuration:0];

   //   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

   //   [UIViewsetAnimationTransition:UIViewAnimationTransitionFlipFromLeftforView:self.view cache:YES];

    pageScroll.contentOffset=CGPointMake(320*whichPage, 0);

   [UIViewcommitAnimations];

}



@end


在根视图2中

#import


@interface NextViewController :UIViewController


@end


#import"NextViewController.h"


@interface NextViewController()


@end


@implementationNextViewController


-(id)initWithNibName:(NSString *)nibNameOrNilbundle:(NSBundle*)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

       // Custominitialization

    }

   return self;

}


-(void)viewDidLoad

{

   [superviewDidLoad];

   self.view.backgroundColor = [UIColor redColor];

// Do any additional setup after loading the view.

}


-(void)viewDidUnload

{

   [superviewDidUnload];

   // Release any retained subviews of themain view.

}


-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return (interfaceOrientation ==UIInterfaceOrientationPortrait);

}


@end


源码下载地址:http://www.kuaipan.cn/file/id_71249139458899969.htm
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
第七课
IOS UI 第四篇:基本UI
用定时器控制滚动视图UIScrollView
iOS开发笔记(Swift)-通用App安装引导页的实现
iOS开发 自定义UIAlertView 继承UIView
iOS开发
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服