cole cole -3 years ago 103
iOS Question

self?.performSegue is not showing navigation bar

self?.performSegue(withIdentifier: "myview", sender: nil)

Above code do not show the navigation bar even though I use push in storyboard.
Below code is shows me an error, even though the segue with correct name exist

self?.navigationController?.performSegue(withIdentifier: "myview", sender: nil)


Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'myview''

Answer Source

self?.navigationController?.performSegue(withIdentifier: "myview", sender: nil) The segue is attached to a UIViewController subclass instance and not to a UINavigationController instance, so you cannot call it on the latter.

If you don't have a navigation bar after performing a segue, you have to make sure that you properly embedded your view controller in a navigation controller or if you added the navigation bar manually, make sure you add it to your other view controller as well in the viewWillAppear method.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download