本文介绍了在应用的整个生命周期中仅显示一次视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发购物应用程序,并正在启动应用程序,它显示注册视图,一旦单击跳过"按钮,它将导航到主视图.我只想在应用的整个生命周期内仅显示一次注册视图.
I am working on a shopping app and on app launch, it shows signup view and once skip button is clicked it navigates to home view. I want to show signup view just once in whole life time of an app.
推荐答案
在这里添加了我用来在整个应用程序生命周期中仅显示一次漫游屏幕的代码.这对您可能有用.
Adding here the code I used to show walkthrough screen only once in the entire application lifecycle. This can be useful to you.
// show walkthough for first time only (first time the app launches after download).
bool shownFlag = [[NSUserDefaults standardUserDefaults] boolForKey:@"walkthroughShownOnce"];
if(!shownFlag){
[[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:@"walkthroughShownOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
WalkThroughViewController *vc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"WalkThroughViewController"];
[self.window makeKeyAndVisible];
[self.window setRootViewController:vc];
}else{
//if not walkthough go and check other task
}
这篇关于在应用的整个生命周期中仅显示一次视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!