这个功能的重点就是在如何判断应用是第一次启动的. 其实很简单

我们只需要在一个类里面写好用户引导页面  基本上都是使用UIScrollView 来实现,

新建一个继承于UIViewController的类 命名为 UserGuideViewController ,

在UserGuideViewController.m 写

1 - (void)viewDidLoad
 2 {
 3     [super viewDidLoad];
 4     // Do any additional setup after loading the view.
 5     self.view.backgroundColor = [UIColor redColor];
 6    
 7     [self initGuide];   //加载新用户指导页面
 8 }
 9
10 - (void)initGuide
11 {
12     UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 640)];
13     [scrollView setContentSize:CGSizeMake(1280, 0)];
14     [scrollView setPagingEnabled:YES];  //视图整页显示
15     //    [scrollView setBounces:NO]; //避免弹跳效果,避免把根视图露出来
16    
17     UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
18     [imageview setImage:[UIImage imageNamed:@"0.png"]];
19     [scrollView addSubview:imageview];
20     [imageview release];
21    
22     UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(320, 0, 320, 460)];
23     [imageview1 setImage:[UIImage imageNamed:@"1.png"]];
24     [scrollView addSubview:imageview1];
25     [imageview1 release];
26    
27     UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(640, 0, 320, 460)];
28     [imageview2 setImage:[UIImage imageNamed:@"2.png"]];
29     [scrollView addSubview:imageview2];
30     [imageview2 release];
31    
32     UIImageView *imageview3 = [[UIImageView alloc] initWithFrame:CGRectMake(960, 0, 320, 460)];
33     [imageview3 setImage:[UIImage imageNamed:@"3.png"]];
34     imageview3.userInteractionEnabled = YES;    //打开imageview3的用户交互;否则下面的button无法响应
35     [scrollView addSubview:imageview3];
36     [imageview3 release];
37    
38     UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//在imageview3上加载一个透明的button
39     [button setTitle:nil forState:UIControlStateNormal];
40     [button setFrame:CGRectMake(46, 371, 230, 37)];
41     [button addTarget:self action:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside];
42     [imageview3 addSubview:button];
43    
44     [self.view addSubview:scrollView];
45     [scrollView release];
46 }
button的方法

1 - (void)firstpressed
2 {
3     [self presentModalViewController:[[[WeiBoViewController alloc] init] autorelease] animated:YES];  //点击button跳转到根视图
4 }

至于添加button是因为我的用户引导最后一个页面有一个画上去的button,写着 开始使用  我在上面添加一个透明的button 用以实现调用方法

打开AppDelegate.m

首先引入头文件

1 #import "UserGuideViewController.h"
2 #import "WeiBoViewController.h"
WeiBoViewController是我的根视图application: didFinishLaunchingWithOptions: 方法内进行判断

1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 2 {
 3     self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
 4     // Override point for customization after application launch.
 5    
 6     //判断是不是第一次启动应用
 7     if(![[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"])
 8     {
 9         [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
10         NSLog(@"第一次启动");       
11         //如果是第一次启动的话,使用UserGuideViewController (用户引导页面) 作为根视图
12         UserGuideViewController *userGuideViewController = [[UserGuideViewController alloc] init];
13         self.window.rootViewController = userGuideViewController;
14         [userGuideViewController release];
15     }
16     else
17     {
18         NSLog(@"不是第一次启动");
19         //如果不是第一次启动的话,使用LoginViewController作为根视图
20         WeiBoViewController *weiBoViewController = [[WeiBoViewController alloc] init];
21         self.window.rootViewController = weiBoViewController;
22         [weiBoViewController release];
23
24     }
25    
26     self.window.backgroundColor = [UIColor whiteColor];
27     [self.window makeKeyAndVisible];
28     return YES;
29 }

iOS开发之应用首次启动显示用户引导的更多相关文章

  1. iOS开发 首次启动显示用户引导,第二次启动直接进入App,UIScrollView,UIPageControl,NSUserDefaults

    首先创建一个引导图的控制器类 UserGuideViewController.h和UserGuideViewController.m #import <UIKit/UIKit.h> #im ...

  2. iOS-王云鹤 APP首次启动显示用户指导

    这个功能的重点就是在如何判断应用是第一次启动的. 其实很简单 我们只需要在一个类里面写好用户引导页面  基本上都是使用UIScrollView 来实现, 新建一个继承于UIViewController ...

  3. iOS开发UI篇—程序启动原理和UIApplication

    iOS开发UI篇—程序启动原理和UIApplication   一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就 ...

  4. iOS开发UI篇—程序启动原理和UIApplication1

    iOS开发UI篇—程序启动原理和UIApplication   一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就 ...

  5. SharedPreference 存储小量数据,一般首次启动显示引导界面就用这个。

    写://添加一个SharedPreference并传入数据SharedPreference sharedPreferences = getSharedPreferences("share_d ...

  6. iOS开发-UIApplication和App启动状态

    UIApplication简单从字面上了解就是应用程序,开发的时候有的时候会根据需要调用其中的方法,看起来不起眼,实际在iOS开发UIApplication提供了iOS程序运行期间的控制和协作工作.每 ...

  7. iOS开发(1) WebView和HTML 显示

    iOS 7 已经release了.现在学习iOS开发还是非常热门的.到处也有些团队在寻找iOS开发的人才. 那么,iOS开发.....省略了1万字.... HTML5 +CSS3+JS...再省略1万 ...

  8. 【转】iOS开发UI篇—程序启动原理和UIApplication

    原文 http://www.cnblogs.com/wendingding/p/3766347.html   一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程 ...

  9. [转载自 文顶顶]iOS开发UI篇—程序启动原理和UIApplication

    一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就代表一个应用程序. (2)每一个应用都有自己的UIApplica ...

随机推荐

  1. Kinect舒适区范围--UE4 的Blueprint测试范例

    本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接: http://blog.csdn.net/cartzhang/article/details/44748475 作者:ca ...

  2. [Angular] Updating and resetting FormGroups and FormControls

    If you want to reset or just update field value, you can do: reset: reset({key: value, k2:v2}); upda ...

  3. [ES6] Use ES6 Proxies

    A JavaScript Proxy allows you to intercept operations performed on objects, arrays, or functions lik ...

  4. 【t075】郁闷的记者

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 你是一个体育报社的记者,你接受到一个艰难的任务:有N支足球队参加足球比赛,现在给你一些比赛的结果,需要 ...

  5. mybatis结合log4j打印SQL日志

    mybatis结合log4j打印SQL日志 1.Maven引用jar包 默认的mybatis不能打印出SQL日志,不便于查看调试,须要结合log4jdbc-log4j2就能够完整的输入SQL的调试信息 ...

  6. 小强的HTML5移动开发之路(28)—— JavaScript回顾3

    一.基本数据类型 number:数字类型 string:字符串 (注意s小写:string是基本类型) boolean:布尔类型   //前三个都有对应的包装类 null:空类型 undefined: ...

  7. hadoop 3.x 启动过程中 Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

    出现这种状况是因为当前账号没有配置ssh免密登录 进入到以下目录,查看是否生成过秘钥对,如果有的话直接ssh-copy-id 主机名 没有的话执行ssh-keygen -t rsa后再重新执行ssh- ...

  8. tomcat启动时自动加载一个类 MyServletContextListener

    目的: 我们知道在tomcat启动后,需要页面请求进行驱动来执行操作接而响应.我们希望在tomcat启动的时候能够自动运行一个后台线程,以处理我们需要的一些操作.因此需要tomcat启动时就自动加载一 ...

  9. visual studio 2015安装win10 SDK文件校验错误的解决方法

    这段时间想看一下UWP开发,于是下载了visual 2015 update1社区版,但是在安装完成时提示,windows 10 sdk文件校验码错误,如下图(图片是借用的,我当时没有截屏,错误号是一样 ...

  10. git 合并本地分支到远程分支

    第一种方法: git 快速合并本地分支到远程分支1.git branch -a 查看所有分支2.git checkout origin/分支名称3.git checkout 分支名称完成 ------ ...