天天看點

新特性顯示

    //從info.plist檔案中讀出版本号

    NSString *key = (NSString *)kCFBundleVersionKey;

    NSString *path = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];

    NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:path];

    NSString *Version = dic[key];

    //    NSString *Version = [NSBundle mainBundle].infoDictionary[key];

    //

    //從沙盒中取出上次存儲的版本号

    NSString *saveVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];

    if ([Version isEqualToString:saveVersion]) {

        //不是第一次時直接進入首頁面

        //顯示狀态欄

        ViewController *login = [ViewController new];

        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];

        login = [storyboard instantiateViewControllerWithIdentifier:@"login"];

        //UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:tea];

        self.view.window.rootViewController = login;

    }else{

        //版本号不一樣,第一次使用新版本

        //将新版本寫入沙盒

        [[NSUserDefaults standardUserDefaults]setObject:Version forKey:key];

        //馬上同步更新NSUserDefaults.

        [[NSUserDefaults standardUserDefaults] synchronize];

        //x顯示新版本特性介紹

        newFeature *newfeature = [newFeature new];

        [self presentViewController:newfeature animated:NO completion:nil];

    }