IOS中新手引导页面的实现(新手引导,Guide)
1.由于项目的需要,我今天学习了新手的引导,接下我来说下新手引导的使用方法:(在程序中运行一次)接下来是实现代码:
在AppDelegate.m 的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIViewController *root;
BOOL answer= [[NSUserDefaults standardUserDefaults]boolForKey:@"answer"];
if (!answer) {
root = [[WecomeViewController1 alloc]init]; //欢迎界面的,就是介绍产品的新特性
}
else{
root = [[TestViewController alloc]init];
}
self.window.rootViewController = root;
[self.window makeKeyAndVisible];
return YES;
}
在需要调用的的时候实现的代码为:
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSString *anwerLabel = self.anwerLabel.text;
if([anwerLabel isEqualToString:@""]){
[self showString:@"答案错误,不要太生气!!"];
return;
}
if([anwerLabel isEqualToString:@"1234"]){
[self showString:@"恭喜你回答正确!!"];
TestViewController *testVC = [[TestViewController alloc]init];
[self presentViewController:testVC animated:NO completion:nil];
//在这里设置判断是否为第一次,然后设置同步
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"answer"];
[[NSUserDefaults standardUserDefaults]synchronize];
}
}
希望可以帮助有需要的人!欢迎你们提出宝贵的意见!!