如何知道第一次使用这个版本?比较上次的使用情况
2015-05-22 18:40
621 查看
//
// HMControllerTool.h
// 黑马微博
//
// Created by apple on 14-7-8.
// Copyright (c) 2014年 heima. All rights reserved.
// 负责控制器相关的操作
#import <Foundation/Foundation.h>
@interface HMControllerTool :
NSObject
/**
* 选择根控制器
*/
+ (void)chooseRootViewController;
@end
-------------------------------------------------------------------------------------------
//
// HMControllerTool.m
// 黑马微博
//
// Created by apple on 14-7-8.
// Copyright (c) 2014年 heima. All rights reserved.
//
#import "HMControllerTool.h"
#import "HMTabBarViewController.h"
#import "HMNewfeatureViewController.h"
@implementation HMControllerTool
+ (void)chooseRootViewController
{
//
如何知道第一次使用这个版本?比较上次的使用情况
NSString *versionKey = (__bridge
NSString *)kCFBundleVersionKey;
//
从沙盒中取出上次存储的软件版本号(取出用户上次的使用记录)
NSUserDefaults *defaults = [NSUserDefaults
standardUserDefaults];
NSString *lastVersion = [defaults objectForKey:versionKey];
//
获得当前打开软件的版本号
NSString *currentVersion = [NSBundle
mainBundle].infoDictionary[versionKey];
UIWindow *window = [UIApplication
sharedApplication].keyWindow;
if ([currentVersion isEqualToString:lastVersion]) {
//
当前版本号 == 上次使用的版本:显示HMTabBarViewController
[UIApplication
sharedApplication].statusBarHidden =
NO;
window.rootViewController = [[HMTabBarViewController
alloc] init];
} else {
// 当前版本号 !=
上次使用的版本:显示版本新特性
window.rootViewController = [[HMNewfeatureViewController
alloc]
init];
//
存储这次使用的软件版本
[defaults
setObject:currentVersion
forKey:versionKey];
[defaults
synchronize];
}
}
@end
// HMControllerTool.h
// 黑马微博
//
// Created by apple on 14-7-8.
// Copyright (c) 2014年 heima. All rights reserved.
// 负责控制器相关的操作
#import <Foundation/Foundation.h>
@interface HMControllerTool :
NSObject
/**
* 选择根控制器
*/
+ (void)chooseRootViewController;
@end
-------------------------------------------------------------------------------------------
//
// HMControllerTool.m
// 黑马微博
//
// Created by apple on 14-7-8.
// Copyright (c) 2014年 heima. All rights reserved.
//
#import "HMControllerTool.h"
#import "HMTabBarViewController.h"
#import "HMNewfeatureViewController.h"
@implementation HMControllerTool
+ (void)chooseRootViewController
{
//
如何知道第一次使用这个版本?比较上次的使用情况
NSString *versionKey = (__bridge
NSString *)kCFBundleVersionKey;
//
从沙盒中取出上次存储的软件版本号(取出用户上次的使用记录)
NSUserDefaults *defaults = [NSUserDefaults
standardUserDefaults];
NSString *lastVersion = [defaults objectForKey:versionKey];
//
获得当前打开软件的版本号
NSString *currentVersion = [NSBundle
mainBundle].infoDictionary[versionKey];
UIWindow *window = [UIApplication
sharedApplication].keyWindow;
if ([currentVersion isEqualToString:lastVersion]) {
//
当前版本号 == 上次使用的版本:显示HMTabBarViewController
[UIApplication
sharedApplication].statusBarHidden =
NO;
window.rootViewController = [[HMTabBarViewController
alloc] init];
} else {
// 当前版本号 !=
上次使用的版本:显示版本新特性
window.rootViewController = [[HMNewfeatureViewController
alloc]
init];
//
存储这次使用的软件版本
[defaults
setObject:currentVersion
forKey:versionKey];
[defaults
synchronize];
}
}
@end
相关文章推荐
- 如何知道SQL SERVER索引的使用情况
- 请教:如何知道当前所用的gcc调用的是哪个版本的glibc库?及这个glibc库的位置?谢谢!
- 请教:如何知道当前所用的gcc调用的是哪个版本的glibc库?及这个glibc库的位置?谢谢!
- Server系列9:如何知道域用户密码的使用情况?(Done)
- ZOL上,下载的这个嵌入版本如何使用
- struts2中,在使用 convention 插件的情况下,如何使用 “chain” 这个result
- 如果你知道如何使用这个技能,就根本不需要担心工作了……
- 如何在更改全局JDK版本1.7.0情况下,让Presto使用JDK1.8.0呢?
- 老男孩教育每日一题-2017年3月20日:使用rsync守护进程模式,经常会出现的异常情况说明,并说明应该如何解决
- 第一次使用Android Studio时你应该知道的一切配置
- 如何使用 sort 命令来找到几个版本库之间的共同文件
- phpcms 2008 sp4的这个版本如何添加一个系统字段
- 如何知道汽车使用哪一种OBD-II通讯协议
- 如何检查 Android 应用的内存使用情况
- 如何使用Logger(比较突出的日志显示)
- 如何让brackets 版本1.9以上 win10下配合默认浏览器edge使用实时预览
- 第一次使用Android Studio时你应该知道的一切配置
- EditText如何在使用数字键盘的情况下输入多个小数点
- 第一次使用Android Studio时你应该知道的一切配置
- 第一次使用Android Studio时你应该知道的一切配置