1.当第一次安装或版本升级时显示新特性界面
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 1.创建window self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor whiteColor]; // 2.根据版本号判断是否选择新特性 [self checkNewFeatureVC]; // 3.显示window [self.window makeKeyAndVisible]; return YES; } - (void)checkNewFeatureVC{ // 2-1.获取软件自身版本 NSDictionary *infoDict = [NSBundle mainBundle].infoDictionary; NSString *currentVersion = infoDict[@"CFBundleShortVersionString"]; // 2-2.获取沙盒中存储的版本号 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *sandboxVersion = [defaults objectForKey:@"oldVersion"]; // 2-3.比较两个版本号,如果软件自身大于沙盒的,保存软件自身的,显示新特性 if([currentVersion compare:sandboxVersion] == NSOrderedDescending){//当前系统版本号和沙盒版本号比较,如果降序 self.window.rootViewController = [[NewFeatureViewController alloc]init]; //2-4.将新版本号保存到沙盒 [[NSUserDefaults standardUserDefaults]setObject:currentVersion forKey:@"oldVersion"]; }else{ self.window.rootViewController = [[ViewController alloc]init]; } }