I have a modal view controller whose view comes from a XIB. I want it to have the same look and feel as the rest of my navigation based app, but it's not a view that's pushed to the navigation stack, it's presented modally. I dragged a UINavigationBar in and made it an outlet, but it doesn't have a title property to set. I have two fields that can bring up this modal view, and I want the title set differently depending on which one creates the modal view.
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
Here is the Simplest way:
you can use existing navigation bar with following code
(Using XCode 4.5.2) Found a method that works directly in Interface Builder - without setting in code.
With the ViewController object selected in (IB), under the Identity Inspector there is a section labeled "User Defined Runtime Attributes". I added the keyPath "title" of type String and set it to the value I wanted.
Tested and this works when pushed onto a Nav Controller stack and when opened modally (with a Modal Nav Controller of course).
UINavigationBar
's manage a stack ofUINavigationItem
s much like aUINavigationController
manager a stack ofUIViewController
s. To set what is visible directly, you should use eitherpushNavigationItem:animated:
orsetItems:animated:
using the navigationItem of the view controller you want the bar to reflect.eg:
The above code where you have a property
navigationBar
which references the stand-alone navigation bar.If you don't want to manage it yourself, you can do as mplappert suggested and nest your view controller (without a stand-alone
UINavigationBar
) in aUINavigationController
and present the navigation controller modally instead of your view controller.in my .h file
Dragged the Child of the navigation item from the storyboard into the .h file
Named it "navigationBarTitle"
in my .m file
Simply put your
UIViewController
into a newUINavigationController
s view controller stack and present that navigation controller modally.