@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //1.创建窗口 self.window = [[UIWindow alloc]init]; self.window.frame = [UIScreen mainScreen].bounds; //2.显示窗口(成为主窗口) [self.window makeKeyAndVisible]; //3.设置窗口根控制器 NSString *key = (NSString *)kCFBundleVersionKey;//获取版本号的key NSString *version = [NSBundle mainBundle].infoDictionary[key];//当前版本号 NSString *saveVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];//取出以前版本号 if ([version isEqualToString: saveVersion]) {//如果相等,版本相同,不进入欢迎页面 self.window.rootViewController = [[TabBarController alloc]init]; }else{//如果不相等,版本不同,进入欢迎页面 self.window.rootViewController = [[NewFeatureController alloc]init];
[[NSUserDefaults standardUserDefaults] setObject:version forKey:key];//存入沙盒中 [[NSUserDefaults standardUserDefaults] synchronize]; } }
以后版本升级只要修改info.plist文件里的 Bundle version 的版本号就行了.