以编程方式单击tabbarController的选项卡 [英] Click a tab of tabbarController programmatically

查看:81
本文介绍了以编程方式单击tabbarController的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个带有Nib文件的标签按钮....

I have 2 tab buttons with Nib files....

按下tab1上的按钮,我希望它显示标签2的视图(不是点击tabbar button2)。我的意思是,我想以编程方式点击第二个标签栏按钮。

On pressing a button on tab1, 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];

所以例如:

- (void)selectNextTabBarView:(id)selector {
  [self.tabBarController setSelectedIndex:1];
}

然后在你需要的按钮上:

and then on your button you need:

[myButton addTarget:self action:@selector(selectNextTabBarView:) forControlEvents:UIControlEventTouchUpInside];

这篇关于以编程方式单击tabbarController的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆