문제

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.

도움이 되었습니까?

해결책

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];
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top