I'm using Xcode 4.6.1 to code on Objective-C. I want to know how can I keep the navigation bar shown when I create a modal segue between 2 View controllers, because I'm doing the segue in the storyboard and when I run the application the navigation bar of the second view controller disappears, and I have a done button on that bar but I can't see it.
相关问题
- CALayer - backgroundColor flipped?
- 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
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How can I add media attachments to my push notific
Just add another
Navigation Controller
to your modal view controller. Follow the stepsModal View Controller
Editor menu
Embed In
Navigation Controller
Run the application. Now it should work perfectly.
Hope this solves your problem.
Modal segues take over the whole screen, so any navigation bars, tool bars, or tab bars that are in the presenting controller will be covered up. If you want a navigation bar on this modal controller, you'll need to add one specifically to it, and add any buttons you want to that new navigation bar (or tool bar). If you don't want to do this, then don't present it modally, do a push to it.
You can add a toolbar programatically by doing the following in
-(void)viewDidLoad
You will then have to create an IBAction for pressing the done button and it is done just like this:
That should give you what you want with your modal view controller.
Here is my SHORTED version of "Volodymyr Nazarkevych" in Swift 4.2
The code of "Volodymyr Nazarkevych" works perfectly, but only when your segue is from 1-ViewController to NavigationController of 2-ViewController, not directly to 2-ViewController. THANKS A LOT VOVA!.
Also in switch cases after destination block code you can do different stuff, for example to get some information or file from second ViewController.
That is probably because you don't have a
UINavigationController
in your modal. You should use one (or just add a navigation bar to your ViewController in the Storyboard), and present that modally.