0

When I click a button in one viewcontroller ,I want to go to other tapbarviewcontroller

  1. I have a tap-bar view controller name "my view" with navigation controller

  2. I have button in that "my view" when I click on button I want to go to public tap-bar view controller

error I am getting is:

when i click on the button its navigating to public view controller but the tap-bar is in the same position in "my view"
help me thanks in advance

Huy Nghia
  • 996
  • 8
  • 22

1 Answers1

1

Here if you have a tabBarController with say 3 View controllers. you are at the first View controller and you click a button which will take you to the 2nd view controller. Write this code in the Action method of the Button

self.tabBarController.selectedIndex = 1; //1 is the index of the array which is self.tabBarController.viewControllers. 

Tabbar controller contains its root view controllers as an array which you can get if you print

self.tabBarController.viewControllers

So accessing for accessing any view controller you have to know its index set it as the tabBarController's selected index.

Hope this helps

Saheb Roy
  • 5,899
  • 3
  • 23
  • 35