简体   繁体   中英

Launch UiView only the first time Storyboard

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?

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.

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"];
    }];
}    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM