Customizing UIModalViewController Size and Having a Navigation Bar
I've created my own ProfileUIViewController
class that is a UINavigationControllerDelegate
. I display this view in two ways:
From an IBAction within
A-UIViewController.m
, as aUIModalViewController
.A-UIViewController
has aUINavigationBar
when it's loaded, but when I display the modal, it no longer has the navigation bar.From clicking a table cell row within
B-UIViewController.m
, by pushing it onto the stack.B-UIViewController
has aUINavigationBar
when it's loaded, and theProfileViewController
keeps the navBar as desired :)
What I am looking to do is keep the UINavigationBar when the view is loaded as a modal in case 1, filling in INSIDE the UINavigationBar instead of laying over the entire view. (IE, I would like the modal to appear within A-UIViewConroller
underneath the navBar - making it a smaller size)
Can someone help me with this? Do I need to make my own custom ModalViewController
class - wouldn't this be P开发者_StackOverflow社区rofileUIViewController
? Does it need some instance methods that I'm not giving it? Any direction would be great:)
The navigation bar is managed by the navigation controller, not by your view controller. When you push your view controller into the navigation controller, the navigation controller uses the information in the navigationItem to determine what to put in the navigation bar. But when you display your view controller modally, it's not inside any navigation controller so there is no bar.
One simple solution for the modal case is to create a new UINavigationController with your view controller as its root view controller, and display that modally instead of displaying your view controller directly.
精彩评论