开发者

Click a tab of tabbarController programmatically

开发者 https://www.devze.com 2023-01-19 05:39 出处:网络
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 tabba

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消