Reputation: 1476
I am using a TabBarController, and from one of the tabs, I want to present another UIViewController, while keeping the TabBar displayed.
If I simply present or push the view controller, it is displayed in full screen, above the TabBar.
What is the right way to solve this issue?
Upvotes: 0
Views: 2150
Reputation: 12144
Assume ViewControllerA
is a UIViewController
of TabBarController
. And the UIViewController
you want to present is ViewControllerB
To push ViewControllerB
, while keeping the TabBar displayed. Simply inside ViewControllerA
you just need to call
ViewControllerB *vc = // Initialize ViewControllerB here
[self.navigationController pushViewController:vc animated:YES];
To present ViewControllerB
ViewControllerB *vc = Initialize ViewControllerB here
vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:vc animated:YES completion:nil];
With presenting, make sure you set UIModalPresentationOverCurrentContext
for modalPresentationStyle
property of ViewControllerB
. If not, it will present fullscreen, over the TabBar
For easier understanding, i created a demo repo, you can take a look.
Upvotes: 1