Reputation: 73
I'm creating an iPhone application, where only the first time the user should select the parameters that will then be stored and no longer required. I asked myself how it was possible to create a view using storyboard that appeared only once. Can you help me?
Upvotes: 1
Views: 571
Reputation: 10808
When the app is launched check if the settings screen has ever been shown before. If it has never been shown before, present the settings view modally using UIViewController
's - (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
method.
// CHECK IF HAVE SHOWN SETTINGS
NSUserDefaults* ud = [NSUserDefaults standardUserDefaults];
BOOL hasShownSettings = [ud boolForKey: @"hasShownSettings"];
// SHOW SETTINGS VIEW
if (!hasShownSettings) {
YourViewController *settingsVC = [[YourViewController alloc] init];
[self presentViewController: settingsVC animated: YES completion:^{
// SAVE THAT WE HAVE SHOWN SETTINGS PAGE
[ud setBool: YES forKey: @"hasShownSettings"];
}];
}
Upvotes: 1
Reputation: 66
Normally any parameters that need to be initialized only once in the view go into the "viewDidLoad" method. Since you are loading the viewController from the storyboard, just look for that method and put the initialization parameters in there.
Upvotes: 1