Search code examples
iosswiftipaduinavigationbarpopover

Showing a navigationbar on a popover


I'm trying to mimic the design of the Calendar app on iOS and I've running into the same issue for several hours now. I'm trying to show a view controller in two different ways, depending on what device the app is running on. If the user is on an iPhone, the view controller is displayed using a push segue. This works fine. If the user is on an iPad, the view controller is supposed to be shown as a popover. This also works, except for the fact that I just CANNOT seem to get a navigation bar to show up when it's displayed as a popover.

Here's an image depicting how I want it to look:

enter image description here


Solution

  • Create a UINavigationController instance with your ViewController as the rootViewController. Then you can present your UINavigationController as a popover. UINavigationController inherits from UIViewController, so it can be presented.