这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
{
}
else
{
guideTourViewController *guide=[self.storyboard instantiateViewControllerWithIdentifier:@"GuideTour"];
guide.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self presentViewController:guide animated:NO completion:nil];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
// This is the first launch ever
}
}
为什么即使第一次启动应用程序,guideTourViewController仍然没有显示?
答案 0 :(得分:0)
似乎是两个连续的过渡问题,如果我是正确的,你可以放入else
部分
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//
guideTourViewController *guide=[self.storyboard instantiateViewControllerWithIdentifier:@"GuideTour"];
guide.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self presentViewController:guide animated:NO completion:nil];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
});
您可以根据需要减少延迟。
希望这会有效..