Change Selected Tab Bar Application Index From Modal View Controller

I am creating a tab bar application using the built-in tab bar application template in Xcode. I have 4 tabs, one of which is mapView. For some of the view controllers, my code programmatically sets the selected index of the tab bar depending on the user's actions. For the mapView view controller, I have a method that presents a modal view when the user clicks on the selected annotation. The modal view contains some information about this selected annotation. I can reject the modal view controller and return to mapView correctly.

My problem is that I would like to place the "home" button on the modular view controller, which should reject the modal view and bring the user to index 0 in the tab bar (AKA home). MapView is an index of 3.

I cannot make [self.tab setSelectedIndex: 0] from a modal view attached to a home button - it does not work. Perhaps I overdid it. Can anyone suggest a solution / hint? I am very grateful! Thank.

+5
source share
1 answer

, parentViewController . .

[(UITabBarController *)self.parentViewController setSelectedIndex:0];
+5

All Articles