Reputation: 1362
I have a UITabBarController with 3 tabs that have VC1, VC2 and VC3 in each of the tabs respectively. In VC1 I have a button that when pressed I want to REPLACE the VC1 with VC4. How do I get the UITabBarController and update the VC array to now be VC4, VC2, VC3. Can I do that inside of VC1 or do I need to post a notification that the appdelegate handles?
Upvotes: 2
Views: 4059
Reputation: 4659
Yes you can do that. You can use UITabBarController
method setViewControllers:animated
, which accepts array of view controllers. The tabs appear in the same order as the array you pass to it (left to right). So just reorder the array and call setViewControllers:animated
with that array. Keep in mind that the tabBarItem
, its image and title is set per view controller. So if you reorder the view controllers your tab bar items will reorder too.
Upvotes: 4