tags:

views:

65

answers:

2

My app is driven by a UITabBarController embedded with a UINavigationController for each individual view within each active tab.

When the app is launched the first time, I'd like to present a separate settings view without a visible TabBar. After the user has completed the setup, they'd be taken to the main view with the TabBar. Also, once configured, the initial configuration view won't be accessible again from within the app although there will be a separate settings section that the user can modify their preferences.

What's a good pattern for doing this?

+1  A: 

Create a configuration setting that the user cannot modify. Call it "FirstRun" or something similar. Set it by default to true. When the user sets their settings for the first time, set it to false.

In your startup code, check the setting and, if true, show your initial settings page.

Randolpho
Having a setting is easy enough, but I am looking for more on how to setup the specific controllers/app logic.
Alexi Groove
just like any other view. You can either create it programatically if FirstRun is not set (within AppDidLaunch) or load a nib from the same place.
Roger Nolan
+1  A: 

You should create a settings completed variable inside NSUserDefaults upon the completion of the settings. If this variable is unset, you know it's the first run.

In your AppDelegate, before you instantiate the UINavigationController, check for the settings variable. If it's not there, take the user to a settings view. Upon completion, remove the settings view, and resume normal code:

BOOL settingsDone = [[NSUserDefaults standardUserDefaults] boolForKey:@"settingsComplete"];

if (settingsDone){
    SettingsView *mySettingsView = [[SettingsView alloc] init];
    [self.window addSubView:mySettingsView.view];
}

//Set up navigationcontroller here

-(void)settingsDone{
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"settingsComplete"];
    for (UIView *view in self.window.subviews){
        [view removeFromSuperView];
    }
}

Just hook the done button in your settings view up to the settingsDone method.

Dan Lorenc