简体   繁体   English

如何在UITabbarViewController中的不同视图之间切换

[英]How to switch between different views in a UITabbarViewController

I tried to use the below code to do the switch: 我试图使用以下代码进行切换:

 [self.tabBarController setSelectedIndex:1];

I notice when I put this in viewDidLoad ... nothing happened. 我注意到,当我将其放在viewDidLoad中时...什么都没发生。 But when I put in separate method, for example, when a button is clicked, it works. 但是,当我使用单独的方法时,例如单击按钮时,它就可以工作。

any body know why? 有谁知道为什么?

What are you trying to achieve? 您想达到什么目的? To manually set the tab being displayed I just set the tab bar's selectedIndex . 要手动设置要显示的标签,只需设置标签栏的selectedIndex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM