Question

My application uses a tab bar controller. My 5th tab is my settings view controller. I want the user during his or her first start-up ever of the app to start on this tab. Does the tab bar controller have a function to display another tab view other then the first? How do I do this? Thanks.

Was it helpful?

Solution

You will have to use the setSelectedIndex: method of the UITabbarController.

Eg:

Considering that your TabBarController object is named aTabbarController

[aTabbarController setSelectedIndex:0];

Now coming to the First Launch Ever, If you want the user to be navigated only during the First Launch and never again,

Use the registerDefaults: method of the NSUserDefaults

Eg:

 [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"FirstLaunch"]];

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]) {
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"FirstLaunch"];
    [aTabbarController setSelectedIndex:0];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top