iOS-王云鹤 APP首次启动显示用户指导
这个功能的重点就是在如何判断应用是第一次启动的. 其实很简单
我们只需要在一个类里面写好用户引导页面 基本上都是使用UIScrollView 来实现,
新建一个继承于UIViewController的类 命名为 UserGuideViewController ,
在UserGuideViewController.m 写
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColorredColor];
[selfinitGuide];//加载新用户指导页面
}
-(void)initGuide{
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 640)];
[scrollView setContentSize:CGSizeMake(1280, 0)];
[scrollView setPagingEnabled:YES]; //视图整页显示
UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
[imageview setImage:[UIImage imageNamed:@"0.png"]];
[scrollView addSubview:imageview];
[imageview release];
UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(320, 0, 320, 460)];
[imageview1 setImage:[UIImage imageNamed:@"1.png"]];
[scrollView addSubview:imageview1];
[imageview1 release];
UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(640, 0, 320, 460)];
[imageview2 setImage:[UIImage imageNamed:@"2.png"]];
[scrollView addSubview:imageview2];
[imageview2 release];
UIImageView *imageview3 = [[UIImageView alloc] initWithFrame:CGRectMake(960, 0, 320, 460)];
[imageview3 setImage:[UIImage imageNamed:@"3.png"]];
imageview3.userInteractionEnabled = YES; //打开imageview3的用户交互;否则下面的button无法响应
[scrollView addSubview:imageview3];
[imageview3 release];
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];//在imageview3上加载一个透明的button
[button setTitle:@"立即体验" forState:UIControlStateNormal];
[button setFrame:CGRectMake(46, 371, 230, 37)];
[button addTarget:selfaction:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside];
[imageview3 addSubview:button];
[self.view addSubview:scrollView];
[scrollView release];
button.backgroundColor =[UIColorredColor];
}
//Button的方法 ViewController为 指导完之后 点击进入的主视图
- (void)firstpressed{
[selfpresentModalViewController:[[[ViewControlleralloc] init] autorelease] animated:YES]; //点击button跳转到根视图s
}
----------------------------------------------------------
AppDelegate.m 中的代码
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
- (void)dealloc
{
[_window release];
//[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]] autorelease];
//判断是不是第一次启动
if (![[NSUserDefaultsstandardUserDefaults]boolForKey:@"firstLaunch"]) {
[[NSUserDefaultsstandardUserDefaults ]setBool:YESforKey:@"firstLaunch"];
NSLog(@"第一次启动");
//如果是第一次启动 使用UserGuideViewController
UserGuideViewController *userGUideViewController =[[UserGuideViewControlleralloc]init];
self.window.rootViewController =userGUideViewController;
[userGUideViewController release];
}
else{
NSLog(@"不是第一次启动");
//如果不是第一次启动使用应用的的主视图
ViewController *Vc = [[ViewControlleralloc] init];
self.window.rootViewController = Vc;
[Vc release];
}
self.window.backgroundColor = [UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
return YES;
}
相关文章
- ios中改变UIImagePickerController页面的button的文字为中文
- iOS接收null的处理方法
- iOS NSFileManager对沙盒文件及目录添加删除操作
- ios上线流程
- iOS的WebView中使用javascript调用原生的api
- 《iOS组件与框架——iOS SDK高级特性剖析》——第8章,第8.3节UIDocument简介
- ios NSNumber详解
- Android/IOS 微信及浏览器(h5)中唤起本地APP,唤起浮层,然后用外部浏览器打开唤起某本地APP
- iOS网络缓存的系统实现是一个烂尾工程
- 实测iOS Dynamic Framework 对 App 启动时间的影响效果
- iOS创建界面方法的讨论
- iOS APP可执行文件的组成
- iOS App性能优化
- 《iOS应用软件设计之道》—— 1.7 定义纲领
- iOS 推送服务的简易原理与配置
- uni-app知识点:禁止页面返回及如何实现自定义返回逻辑、实现再次返回退出应用时不退出应用而是在后台运行、uni-app ios滑动时卡顿不流畅问题解决方案
- IOS如何获取app跳转app store更新链接(如itms-apps://itunes.apple.com/cn/app/hello-uni-app/id1417078253)
- IOS APP上架App Store及提交审核详细教程
- iOS之crash分析篇--捕获signal类型的崩溃信息
- 升级iOS 10之后 正确的解锁方式是怎样的?
- iOS-第三方登录无法拉起App问题
- iOS - 封装自己的slider
- iOS - WKWebView的使用和长按手势识别二维码并保存
- iOS - 获取安装所有App的Bundle ID
- iOS - 音乐播放器需要获取音乐文件的一些数据信息(封装获取封面图片的类)
- IOS APP 上传到AppStore
- 使用Fiddler进行IOS APP的HTTP抓包