设置引导页在第一次运行时显示,再次运行不显示,版本更新时再次显示引导页
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 创始字符串
NSString *path = [[NSBundle mainBundle] pathForResource:@"Info.plist" ofType:nil];
// 创建字典
NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:path];
// 打印版本的key
NSLog(@"%@",[dic objectForKey:@"CFBundleVersion"]);
// 判断
if ([[dic objectForKey:@"CFBundleVersion"] isEqualToString:[[NSUserDefaults standardUserDefaults] valueForKey:@"yin223"]]) {
// 版本号相同
// 进入主页面
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
}else{
// 版本号不相同
// 进入引导页 -- 此处 forKey 的值要与 if 判断条件中的 valueForKey 保持一致
[[NSUserDefaults standardUserDefaults] setObject:[dic objectForKey:@"CFBundleVersion"] forKey:@"yin223"];
self.window.rootViewController = [[YinDaoYeViewController alloc] init];
}
return YES;
}