简体   繁体   中英

Presenting a new UIViewControler within a UITabBarController

I have a UITabBarController with a NavigationBar. In the NavigationBar is a button which instantiate a new UIViewController with an UINavigationController: self.presentViewController(nav, animated: true, completion: nil) and as i expected the view is presented over fullscreen.

So on, my question is: How can i present the new UIViewController without hiding/overlapping my Tabbar?

You should make sure that you are setting the correct modalPresentionStyle on the view controller you're presenting. Perhaps .CurrentContext or .OverCurrentContext . For this to work you should also set definesPresentationContext to true on the selectedViewController . In your UITabBarController subclass:

nav.modalPresentationStyle = .CurrentContext
self.selectedViewController?.definesPresentationContext = true
self.selectedViewController?.presentViewController(nav, animated: true, completion: nil)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM