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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…