iOS开发之应用首次启动显示用户引导
这个功能的重点就是在如何判断应用是第一次启动的. 其实很简单
我们只需要在一个类里面写好用户引导页面 基本上都是使用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开发之应用首次启动显示用户引导的更多相关文章
- iOS开发 首次启动显示用户引导,第二次启动直接进入App,UIScrollView,UIPageControl,NSUserDefaults
首先创建一个引导图的控制器类 UserGuideViewController.h和UserGuideViewController.m #import <UIKit/UIKit.h> #im ...
- iOS-王云鹤 APP首次启动显示用户指导
这个功能的重点就是在如何判断应用是第一次启动的. 其实很简单 我们只需要在一个类里面写好用户引导页面 基本上都是使用UIScrollView 来实现, 新建一个继承于UIViewController ...
- iOS开发UI篇—程序启动原理和UIApplication
iOS开发UI篇—程序启动原理和UIApplication 一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就 ...
- iOS开发UI篇—程序启动原理和UIApplication1
iOS开发UI篇—程序启动原理和UIApplication 一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就 ...
- SharedPreference 存储小量数据,一般首次启动显示引导界面就用这个。
写://添加一个SharedPreference并传入数据SharedPreference sharedPreferences = getSharedPreferences("share_d ...
- iOS开发-UIApplication和App启动状态
UIApplication简单从字面上了解就是应用程序,开发的时候有的时候会根据需要调用其中的方法,看起来不起眼,实际在iOS开发UIApplication提供了iOS程序运行期间的控制和协作工作.每 ...
- iOS开发(1) WebView和HTML 显示
iOS 7 已经release了.现在学习iOS开发还是非常热门的.到处也有些团队在寻找iOS开发的人才. 那么,iOS开发.....省略了1万字.... HTML5 +CSS3+JS...再省略1万 ...
- 【转】iOS开发UI篇—程序启动原理和UIApplication
原文 http://www.cnblogs.com/wendingding/p/3766347.html 一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程 ...
- [转载自 文顶顶]iOS开发UI篇—程序启动原理和UIApplication
一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就代表一个应用程序. (2)每一个应用都有自己的UIApplica ...
随机推荐
- HDU 1243 反恐训练营 (动态规划求最长公共子序列)
反恐训练营 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- Android JNI编程(三)——C语言指针的初步认识、指针变量、互换两个数、函数返回多个值
版权声明:本文出自阿钟的博客,转载请注明出处:http://blog.csdn.net/a_zhon/. 目录(?)[+] 一.什么是指针? 简单来说: 指针就是内存地址 内存地址就是指针. ...
- 1069. The Black Hole of Numbers (20)【模拟】——PAT (Advanced Level) Practise
题目信息 1069. The Black Hole of Numbers (20) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B For any 4-digit inte ...
- 古语云:工欲善其事必先利其器 --> 最新、最全的 IntelliJ IDEA(2018.3.3) 的介绍、安装、破解、配置与使用
原文:古语云:工欲善其事必先利其器 --> 最新.最全的 IntelliJ IDEA(2018.3.3) 的介绍.安装.破解.配置与使用 一.IntelliJ IDEA 介绍 -> Ecl ...
- Python 库的使用 —— dis
dis:Disassembler of Python byte code into mnemonics. Java.Python.Ruby 1.9 这些语言均使用了栈机器型的 VM.因为是基于栈的实现 ...
- 数码测色计获取UIColor的RGB
1.打开电脑数码测色计 2.鼠标移动到需要的颜色上 3.获取相应RGB值: [UIColor colorWithRed:204.f/255.f green:0.f/255.f blue:212.f/2 ...
- MapReduce 切片机制源码分析
总体来说大概有以下2个大的步骤 1.连接集群(yarnrunner或者是localjobrunner) 2.submitter.submitJobInternal()在该方法中会创建提交路径,计算切片 ...
- android 流量统计
1 android通过架构流量统计TrafficStats类可以直接获得 获得总流量受理TrafficStats.getTotalRxBytes(), 获得总传出流量TrafficSt ...
- TstringBuilder Delphi2007版
2010中的StringBuilder对象用的比较爽快!于是稍作了一些修改(增加了几个函数和属性)然后移植到D2007中来使用了!效果不错,共享一下! unit DxStringBuilder; in ...
- linux tesseract识别名片
用tesseract识别名片,无任何训练 数字,字母识别的准确率比较高,没有错误,规范的汉字识别的还可以,比如名片背面,正面的就错误比较多了: 没有任何训练,识别的还算可以了:我们主要要的电话和QQ ...