Swift - 从按钮单击打开特定选项卡

Moa*_*han 2 ios swift

我实现了一个UITabBarController并实现了一些选项卡.现在我有一个按钮UITabBarItem,我想切换到特定的选项卡.我已经看到使用导航控制器的答案,但在我的情况下,我没有使用导航控制器.

注意:我已从互联网复制此屏幕截图,因此请忽略导航栏.我想要一个不使用导航控制器的答案.

Adi*_*ava 11

只需使用它.

self.tabBarController.selectedIndex = indexToWhichYouWantToMove;
Run Code Online (Sandbox Code Playgroud)

tabBarController 是你的对象 TabBarController