应用首次启动引入导图
来源:互联网 发布:mac 照片 相簿 文件夹 编辑:程序博客网 时间:2024/05/28 15:07
#import "ViewController.h"
#import "FirstTimeLoadJudge.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//取对应的Key (记录用户打开app次数)的整型值,直接加1
[FirstTimeLoadJudgerecordAppOpenTimes];
//基本设置:先进入ViewController中
self.window = [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
ViewController *view = [[ViewControlleralloc]init];
self.window.rootViewController = view;
[self.windowmakeKeyWindow];
returnYES;
}
//FirstTimeLoadJudge中的类方法
@interface FirstTimeLoadJudge :NSObject
// 记录应用程序的打开次数
+ (void)recordAppOpenTimes;
//返回应用程序的打开次数
+ (NSInteger)appOpenTimes;
//是否是第一次打开应用程序
+ (BOOL)isFirstTimeOpenAPP;
@end
#import "FirstTimeLoadJudge.h"
#define kAppOpenTimes @"kAppOpenTimes"
@implementation FirstTimeLoadJudge
//记录应用打开次数
+ (void)recordAppOpenTimes{
//取出打开次数
NSInteger times = [[NSUserDefaultsstandardUserDefaults]integerForKey:kAppOpenTimes];
//每打开一次次数+1
times++;
//将当前次数写入其中
[[NSUserDefaultsstandardUserDefaults]setInteger:timesforKey:kAppOpenTimes];
}
//查看应用打开的次数
+ (NSInteger)appOpenTimes{
return [[NSUserDefaultsstandardUserDefaults]integerForKey:kAppOpenTimes];
}
//是否是第一次打开应用程序
+ (BOOL)isFirstTimeOpenAPP{
if ([FirstTimeLoadJudgeappOpenTimes] ==1) {
returnYES;
}else{
returnNO;
}
}
//ViewController中实现功能
#import "ViewController.h"
#import "FirstTimeLoadJudge.h"
#import "RootViewController.h"
#import "AppDelegate.h"
#define VIEW_WIDTH [[UIScreen mainScreen] bounds].size.width
#define VIEW_HEIGHT [[UIScreen mainScreen] bounds].size.height
@interface ViewController ()
@property (nonatomic,strong)UIScrollView *scrollView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColorblueColor];
//判断应用程序是否是第一次打开如果是第一次打开
if ([FirstTimeLoadJudgeisFirstTimeOpenAPP]) {
NSLog(@"用户第一次打开应用程序");
//显示新特性界面
[selfshowNewFunction];
}else{//不是第一次打开
//切换Window的根视图控制器
RootViewController *root = [[RootViewControlleralloc]init];
AppDelegate *appDelegate = (AppDelegate *)[UIApplicationsharedApplication].delegate;
appDelegate.window.rootViewController = root;
}
}
- (void)showNewFunction{
NSLog(@"显示导图界面");
//准备5张图片
NSArray *imageArray =@[@"helpphoto_one",@"helpphoto_two",@"helpphoto_three",@"helpphoto_four",@"helpphoto_five"];
self.scrollView = [[UIScrollViewalloc]initWithFrame:CGRectMake(0,0, VIEW_WIDTH,VIEW_HEIGHT)];
[self.viewaddSubview:self.scrollView];
//图片的个数
NSInteger imageCount = imageArray.count;
//内容尺寸
self.scrollView.contentSize =CGSizeMake(VIEW_WIDTH * imageCount,VIEW_HEIGHT);
//按页滚动
self.scrollView.pagingEnabled = YES;
self.scrollView.bounces =NO;
self.scrollView.showsHorizontalScrollIndicator = NO;
//往scrollView上添加图片
for (NSInteger i =0; i < imageCount; i++ ) {
UIImageView *imageView = [[UIImageViewalloc]initWithFrame:CGRectMake(i *VIEW_WIDTH, 0,VIEW_WIDTH, VIEW_HEIGHT)];
NSString *imageName = imageArray[i];
//如果是网络图片
//[imageView sd_setImageWithURL:[NSURL URLWithString:imageName] placeholderImage:[UIImage imageNamed:@""]];
//本地图片
imageView.image = [UIImageimageNamed:imageName];
if (i == imageCount -1) {
imageView.userInteractionEnabled =YES;
//在最后一张图片上添加一个进入主界面的按钮
UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeCustom];
btn.frame =CGRectMake(120,50, 100,50);
[btn setTitle:@"开始体验"forState:UIControlStateNormal];
[btn setTitleColor:[UIColoryellowColor] forState:UIControlStateNormal];
btn.backgroundColor = [UIColorpurpleColor];
[btn addTarget:selfaction:@selector(btnPressed:)forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:btn];
}
//滚动视图上添加imageView
[self.scrollViewaddSubview:imageView];
}
}
- (void)btnPressed:(UIButton *)btn{
RootViewController *root = [[RootViewControlleralloc]init];
AppDelegate *appDelegate = (AppDelegate *)[UIApplicationsharedApplication].delegate;
//切换根视图控制器
appDelegate.window.rootViewController = root;
}
// RootViewController为导图进入后的主界面内容
- 应用首次启动引入导图
- iOS判断应用是否首次启动
- Linux 首次引入 nftables
- 首次启动
- 首次启动
- iOS 开发之应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- iOS开发笔记--应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- iOS--应用首次启动的引导页
- iOS开发之应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- iOS开发笔记--应用首次启动显示用户引导
- iOS开发之应用首次启动显示用户引导
- Kaptcha参数介绍
- ultraEdit格式化代码
- ajax同步开发——json+对应的处理方式直接贴上被我滥用的代码标本吧:
- Ural 1635. Mnemonics and Palindromes
- SubmitOncePage:解决刷新页面造成的数据重复提交问题
- 应用首次启动引入导图
- 十一种通用滤波算法(转)
- iOS 获取当前网络状态(转载)
- shell 常用命令整理
- 文字处理以及tf使用_android原生
- RFC6020 - YANG语言标准中文
- 解决ie打开url返回json/map自动下载
- MFC关闭窗口 退出软件的 用法
- 关于JS原型链