[英]why the detect first launch or not method does not work
這是我的代碼:
- (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仍然不顯示?
似乎有兩個連續的過渡問題,如果我是對的,你可以放在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];
});
您可以根據需要減少延遲。
希望這會工作..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.