Change the selected TabBar index on button click

前端 未结 4 409
抹茶落季
抹茶落季 2021-01-29 11:27

In my app I have 4 tabs, on the first Tab : I have 4 views. on second view,there is one button which will open the third tab view. But my selected tab Index is One. How can I ch

相关标签:
4条回答
  • 2021-01-29 11:41

    In Swift 2, you can just call:

        self.tabBarController?.selectedIndex = 0
    
    0 讨论(0)
  • 2021-01-29 11:50
     self.tabBarController.selectedViewController=[self.tabBarController.viewControllers objectAtIndex:3];
    

    Try this. This will helpful for you.

    0 讨论(0)
  • 2021-01-29 11:51

    On Button Click

    [self.navigationController pushViewController:YourView animated:YES];
    [self.tabBarController setSelectedIndex:index];
    
    0 讨论(0)
  • 2021-01-29 11:59

    The simplest way to programatically switch tabs within the app is by doing this ..

    [self.tabBarController setSelectedIndex:3];
    

    I use this in one of my apps and it works extremely well.

    Plasma

    0 讨论(0)
提交回复
热议问题