Question

I'm trying to set up an initial view for my application (introduction page) and after the user confirms this page from henceforth display a tabbed view by default. I'm new to iOS but my first guess would be to create a standard view controller and set it as initial view. Then when the user presses ok, store the value to file and load the value every time the app is opened. If they have already pressed ok navigate to the tabbed screen instead.

My second option would probably be to show some type of dialogue box that covers the tabbed view completely which would probably be simpler. I'm not sure.

The problem with most approaches suggested here though is that they do not use a storyboard (Regarding the suggestion of editing the app delegate). Are the ways I outlined above the proper ways of solving this? If not could someone provide some guidance on how to accomplish this.

Like I said before this is all pretty new (coming from WP7) so sorry if I didn't state the correct terms. I appreciate your time.

Was it helpful?

Solution

Assuming your first tab's view controller is named FirstViewController. Edit the FirstViewController's viewDidLoad:

- (void)viewDidLoad {
   [super viewDidLoad];

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    BOOL alreadyShownWelcomeScreen = [defaults boolForKey:@"alreadyShownWelcomeScreen"];
    if (alreadyShownWelcomeScreen) {
        // Already shown welcome screen. Do nothing.
    } else {
        // Show welcome screen

        WelcomeViewController *controller = [[WelcomeViewController alloc] initWithNibName:@"WelcomeViewController" bundle:nil];
       [self presentModalViewController:controller animated:YES];

       // Update NSUserDefaults.
       [defaults setBool:YES forKey:@"alreadyShownWelcomeScreen"];
       [defaults synchronize];
    }

Note: this will only work if you always launch with FirstViewController. If you want to persist state and launch the app in a different tab, you'll have to move this code somewhere else (e.g. AppDelegate.m).

OTHER TIPS

You could also do this all from within a storyboard. Your initial view controller can have a segue to the tabbed controller and it will only follow that segue given your conditions are met.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top