111.獲取根視圖(控制權(quán))的三種方法
注:在項(xiàng)目一種的WXMovie中的GuideViewController中
//設(shè)置window的根視圖
//1通過self.view獲取window
self.view.window.rootViewController= tabBarC;
//2通過APPDelegate對(duì)象獲取window
AppDelegate*appdelegate = [UIApplicationsharedApplication].delegate;
appdelegate.window.rootViewController= tabBarC;
//3直接獲取
[UIApplicationsharedApplication].keyWindow.rootViewController= tabBarC;
222.啟動(dòng)界面的設(shè)置
注:具體代碼在項(xiàng)目一WXMovie中的APPDelegate中
//如果第一啟動(dòng)的話,就在沙盒中設(shè)置一個(gè)值,等到以后每一次運(yùn)行的時(shí)候,都判斷下該值
//1 path路徑
NSString*path = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/dic.plist"];
//2讀取本地的文件(返回的是字典)
NSDictionary*isFirstDic = [NSDictionarydictionaryWithContentsOfFile:path];
//注:第一次運(yùn)行該值是NO
BOOLnoFirst = [[isFirstDicobjectForKey:@"noFirst"]boolValue];
if(noFirst) {//不是第一次
//進(jìn)入啟動(dòng)界面
LauchViewController*lauchVC = [[LauchViewControlleralloc]init];
self.window.rootViewController= lauchVC;
}else{//是第一次
//引導(dǎo)界面
GuideViewController*guideVC = [[GuideViewControlleralloc]init];
self.window.rootViewController= guideVC;
//創(chuàng)建字典
NSMutableDictionary*dic = [NSMutableDictionarydictionary];
[dicsetObject:@"YES"forKey:@"noFirst"];
//將一個(gè)字典寫入到一個(gè)路徑中(自動(dòng)創(chuàng)建plist文件)
[dicwriteToFile:pathatomically:YES];
}