Reputation: 596
My Apps main view is having 5 buttons and I'm having tabbarcontroller with 5 tabs.So I need to select each tabs from each button action. Thanks in advance
Upvotes: 0
Views: 141
Reputation: 10755
Use
self.tabBarController.selectedIndex = i;
insted of i write the number of tab witch you wish !!!
Upvotes: 1
Reputation: 11145
assign tags to each button in view as 0,1,2,3,4 and use the same action for all buttons as
- (IBAction)selectTab:(id)sender
{
UIButton *button = (UIButton*)sender;
[self.tabBarController setSelectedIndex:[button tag]];
[self.tabBarController.view setNeedsDisplay];
}
Upvotes: 0
Reputation: 27073
Do something like this:
- (IBAction)selectSecondTab:(id)sender {
self.tabBarController.selectedIndex = 1;
[self.tabBarController.view setNeedsDisplay];
}
Upvotes: 2