IOS9 新特性对比
IOS9 新特性
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#pragma mark -屏幕适配
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window = window;
[NSThread sleepForTimeInterval:1.0];
//判断是否需要显示:(内部已经考虑版本及本地版本缓存)
BOOL canShow = [GuidePageViewController canShowNewFeature];
//测试代码,正式版本应该删除
canShow = YES;
if(canShow){ // 初始化新特性界面
window.rootViewController = [GuidePageViewController newFeatureVCWithImageNames:@[@"new1",@"new2",@"new3",@"new3"] enterBlock:^{
NSLog(@"进入主页面");
[self enter];
} configuration:^(UIButton *enterButton) { // 配置进入按钮
[enterButton setBackgroundImage:[UIImage imageNamed:@"btn_nor"] forState:UIControlStateNormal];
[enterButton setBackgroundImage:[UIImage imageNamed:@"btn_pressed"] forState:UIControlStateHighlighted];
enterButton.bounds = CGRectMake(0, 0, 120, 40);
enterButton.center = CGPointMake(KScreenW * 0.5, KScreenH* 0.85);
}];
}else{
[self enter];
}
[window makeKeyAndVisible];
return YES;
}
###IOS9前版本
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
NSString* key = (NSString *)kCFBundleVersionKey;
//1.从Info.plist取出版本号
NSString* version = [NSBundle mainBundle].infoDictionary[key];
//2.从沙盒中取出上次存储的版本号
NSString* saveVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
if([version isEqualToString:saveVersion])
{
self.window.rootViewController = [[ MainviewController alloc]init];
}else{ //将新版本写入沙盒
[[NSUserDefaults standardUserDefaults]setObject:version forKey:key];
[[NSUserDefaults standardUserDefaults]synchronize];//立即存储
self.window.rootViewController = [[NewFeatureController alloc]init];
}
}