//首先判断app是否是第一次运行,然后根据情形切换根视图
self.window=[[UIWindow alloc]init];
self.window.frame=[[UIScreen mainScreen]bounds];
self.window.backgroundColor=[UIColor whiteColor];
NSUserDefaults*userdefault=[NSUserDefaults standardUserDefaults];//;利用归档
BOOL isFisrt = [userdefault boolForKey:@"isFirst"];
if (isFisrt) {
NSLog(@"不是第一次运行");
self.window.rootViewController = [[ViewController alloc]init];
[self.window makeKeyAndVisible];
}
else
{
NSLog(@"是第一次运行");
self.window.rootViewController=[[NextViewController alloc]init];
[userdefault setBool:YES forKey:@"isFirst"];
[userdefault synchronize];
[self.window makeKeyAndVisible];
}
//要想切换到原来的根视图
ViewController *bookView = [[ViewController alloc] init];
[UIApplication sharedApplication].delegate.window.rootViewController = bookView;