在沙盒中存储程序版本号 显示新特性
//获取上一次存入沙盒中的版本号 NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"CFBundleVersion"]; NSLog(@"%@",lastVersion); //获取当前版本号 NSDictionary *dic = [NSBundle mainBundle].infoDictionary; NSString *version = dic[@"CFBundleVersion"]; NSLog(@"%@",version); //判断上次和这次的版本号是否一致 if ([lastVersion isEqualToString:version]) { self.window.rootViewController = [[RootTabBatController alloc] init]; } else { //可以点击这个控制器的按钮 跳转到 tabVC 界面 然后在点击方法里面 切换window的根视图控制器 /* * UIWindow *window = [UIApplication shareApplication].keyWindow; * window.rootViewController = [[ARTabBarController alloc] init]; * 这样的话 window 之前的 根视图就会被自动销毁 */ self.window.rootViewController = [[BeginViewController alloc] init]; //将当前版本号存进沙盒 [[NSUserDefaults standardUserDefaults] setValue:version forKey:@"CFBundleVersion"]; [[NSUserDefaults standardUserDefaults] synchronize]; } // 显示窗口 [self.window makeKeyAndVisible];
//然后在BeginViewController控制器的点击方法中 设置window 的根视图控制器 为别的视图控制器 此时
BeginViewController 就会被自动销毁
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { UIWindow *window = [UIApplication sharedApplication].keyWindow; window.rootViewController = [[RootTabBatController alloc] init]; }