LeoNatan / LNPopupController

A framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
MIT License
3.03k stars 340 forks source link

Presenting VC over navigation bar #141

Closed madlyn closed 7 years ago

madlyn commented 7 years ago

Description

I have a tabBar containing a tabBar that is contained in a Navigation Controller.

screen shot 2017-02-27 at 10 53 45 am

I tried to present the popupController from the navigation controller but it hid the tabBar permanently even when I close the popup view. So I used tabBarController?.presentPopupBar(withContentViewController: popupContentController, openPopup: true, animated: true, completion: nil) instead in both tabBars. It worked and i could see the popup everywhere in the app which is what I want but I can't present the VC over the Navigation Controller this way.

screen shot 2017-02-27 at 10 56 57 am

This is when I present it from the Navigation Controller nav

How can I present it properly?

Device, OS and Xcode Versions

Device: MacBook Pro 2016 OS: 10.12.3 Xcode: 8.2.1

LeoNatan commented 7 years ago

Usually, the tab bar controller contains the navigation controller, not the other way. In your case, it’s inverted. As the README says, you should always present from the outer most container controller, which in your case is the outer navigation controller.

madlyn commented 7 years ago

But when I did that the tabBar was hidden permanently and I couldn't get it back (See last pic)

LeoNatan commented 7 years ago

Hmm yes, because then the bottom bar is the navigation controller toolbar, which is hidden, and the popup bar hides the tab bar. If all your pushed view controllers are tab bar controllers, you can subclass the navigation controller to return a custom bottom view, but it will not be smooth.

For best results, I suggest inverting your controller hierarchy so that the tab bar controller is the root controller. This is how it should be. Each tab should have its own navigation controller.

madlyn commented 7 years ago

I'll try that, Thank you!