Objective C: How to switch from one Tab bar to another via program

前端 未结 2 2037
忘掉有多难
忘掉有多难 2021-02-01 18:06

I have 5 different tabs in my tabbar controller.

My intention is to be able to switch from one tab bar via code. For example I am currently in the 5th tab of the app and

2条回答
  •  情话喂你
    2021-02-01 18:10

    Heres a simpler answer (if you know the index of the Tab Bar item is not in the "more" view controllers): just get a reference of the tabController and set the "selectedIndex" property

    self.tabBarController.selectedIndex = 0;
    

    Reference: https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarController_Class/Reference/Reference.html#jumpTo_6

提交回复
热议问题