Reputation: 31657
I have structure of project as shown below.
On the left side I have MainViewController. There I have two buttons as English and Arabic. What I want to do is when I click English, I want to go English tab bar controller (HomeViewController).
Hence what I wrote is
- (IBAction)langEnglish:(id)sender {
HomeViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"enghome"];
[self.navigationController pushViewController:secondView animated:YES];
}
This is working perfectly, but I don't see tab bar.
Tab bar is missing from this.
Any idea what is going wrong?
Basically what I have is view controller as main controller and upon clicking button on this controller, tab view controller should get open...
Upvotes: 3
Views: 4539
Reputation: 31657
What I did is as below
- (IBAction)langEnglish:(id)sender {
EngTabViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"engtab"];
[self.navigationController pushViewController:secondView animated:YES];
}
EngTabViewController is the UITabBarController and I assigned id to tab bar controller... this works like charm...
Means instead of viewcontorller, I used tabbarcontroller...
Upvotes: 1
Reputation: 1506
You shouldn't push a UITabBarController on a UINavigationController. Set it as the window's root view controller instead and the tab bar should be displayed as expected.
Upvotes: 0
Reputation: 6918
Go to your main storyboard and select your main view controller. On top select Editor->Embed in->navigation bar.
EDIT: If this does not work push to your tab bar and use this code:
self.tabBarController.selectedIndex = 1;
Upvotes: 3