I have UIViewController
and UITabBarController
.
UIViewController
contain 5 buttons and UITabBarController
has 5 Tabs.
By tapping first button app shows TabBarController
with the first selected tab, second - TabBarController
with the second tab and so on...
To prepare this I have used Modal-segue
for every button.
Everything works well.
Now I need to create "Home" button (may be programmatically) on TabBarController
's UINavigationBar
, which will execute "Go home view" action.
Edited with more details
{see the screenshot below}
- Initial UIViewController
- UITabBarController
- NavigationControllers
- UIViewControllers
There are TWO modal-segues between 1 and 2 (two buttons - two segues)
In my prepareForSegue in UIViewController:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
AppDelegate *d = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if ([segue.identifier isEqualToString:@"s1"]) {
d.initialTab = 0;
}
else if ([segue.identifier isEqualToString:@"s2"]) {
d.initialTab = 1;
}
}
In my viewDidLoad in UITabBarController:
TabController *mainTabController = (TabController *)self;
AppDelegate *d = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[mainTabController setSelectedIndex:d.initialTab];
This is works!
But I need to go back to home-page. So if there is a NavigationController after TabBarController I would like to create a button in NavigationBar.