Danny Togaer
Danny Togaer

Reputation: 339

How can jump another tab with a single click on a button?

-(void)Save{

 MainScreenContoller *main= [[MainScreenContoller alloc]     initWithNibName:@"MainScreenContoller" bundle:nil];
[self.view.superview addSubview:[main view]];

}

This is the place that i am going to click and my button calls save function.After this i want the application automatically turn to main screen which is the first tab bar this one is the third.

So i click the button and the application switches to the first tab bar.

Upvotes: 1

Views: 185

Answers (2)

filipe
filipe

Reputation: 3380

if you want to select the first tab on the tab bar controller, you can simply do this:

- (void) save
{
    // do your saving here
    // ...

    self.tabBarController.selectedIndex = 0;
}

Upvotes: 1

petert
petert

Reputation: 6692

Try setting this property of UITabBarController:

@property(nonatomic) NSUInteger selectedIndex

So for the first tab, something like:

self.tabBarController.selectedIndex = 0;

From the documentation:

Setting this property changes the selected view controller to the one at the designated index in the viewControllers array. To select the More navigation controller itself, you must change the value of the selectedViewController property instead.

Upvotes: 0

Related Questions