iOS 新特性界面

.m

+ (UIViewController *)chooseRootViewController
{
    UIViewController *rootVc = nil;
    
    // 判斷下用戶有沒有最新的版本
    // 最新的版本都是保存到info.plist
    // 從info.plist文件獲取最新版本
    // 獲取info.plist
    NSString *infoPath = [[NSBundle mainBundle] pathForResource:@"Info.plist" ofType:nil];
    //    NSDictionary *dcit = [NSDictionary dictionaryWithContentsOfFile:infoPath];
    
    NSDictionary *dict =  [NSBundle mainBundle].infoDictionary;
    
    // 獲取最新的版本號
    NSString *curVersion = dict[@"CFBundleShortVersionString"];
    
    // 獲取上一次的版本號
    NSString *lastVersion = [XMGSaveTool objectForKey:XMGVersionKey];
    
    // 之前的最新的版本號 lastVersion
    if ([curVersion isEqualToString:lastVersion]) {
        // 版本號相等
        
        rootVc = [[XMGTabBarController alloc] init];
        
    }else{ // 有最新的版本號
        
        // 保存最新的版本號
        // 保存到偏好設(shè)置
        [XMGSaveTool setObject:curVersion forKey:XMGVersionKey];
        
        // 創(chuàng)建新特性界面
        rootVc = [[XMGNewFeatureViewController alloc] init];
    }
    return rootVc;
}

.h

@interface XMGGuideTool : NSObject

// 選擇窗口根控制器
+ (UIViewController *)chooseRootViewController;

@end

AppDelegate
.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    // 1.創(chuàng)建窗口
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    // 2.設(shè)置窗口的根控制器
    // 選擇根控制器
    self.window.rootViewController = [XMGGuideTool chooseRootViewController];
    
    // 3.顯示窗口
    [self.window makeKeyAndVisible];
    
    return YES;
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容