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 do
Here is my SHORTED version of "Volodymyr Nazarkevych" in Swift 4.2
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
switch(segue.identifier ?? "") {
case "segueIdentifier": // name of your segue
let navigation: UINavigationController = segue.destination as! UINavigationController
//here you create new name of your destination ViewController and assign his name to let constant above
guard let myNewViewController = navigation.viewControllers[0] as? DestinationViewController
//DestinationViewController is your 2-ViewController where you go to from first one.
else {
fatalError("Unexpected destination: \(segue.destination)")
}
// TO DO SOMETHING HERE
default:
fatalError("Unexpected Segue Identifier; \(String(describing: segue.identifier))")
}
}
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.