Click a tab of tabbarController programmatically
I have 2 tab buttons with Nib files....
On pressing a button on tab1, 开发者_StackOverflow中文版I want it want to show tab 2's view (not click on tabbar button2). I mean, I want to click second tabbar button programmatically.
How can I do this, is it possible?
You'll have to create a function with this in it:
[self.tabBarController setSelectedIndex:1];
So eg:
- (void)selectNextTabBarView:(id)selector {
[self.tabBarController setSelectedIndex:1];
}
and then on your button you need:
[myButton addTarget:self action:@selector(selectNextTabBarView:) forControlEvents:UIControlEventTouchUpInside];
精彩评论