Answer the question
In order to leave comments, you need to log in
`
Why isn't a navigation bar automatically created with a back button on show segue?
Hello!
I can't figure out why the Navigation Bar ` and Back Button are not automatically created when a new segue is created? It is not possible to get the desired result through the Xcode interface.
Navigation is the most common: NC (root relation)-> VC (via button) -> AnotherVC
I understand that, most likely, I'm stupid somewhere, but I just can't understand where exactly. Because now I have to solve two problems at once because of this:
Call the `dismiss` method everywhere with my hands and write a function to return back using a left-to-right swipe, but I want to have it out of the box.
Perhaps some of you have experienced this, I will be glad to help!
xcodev. 8.2.1
Thank you in advance!
Answer the question
In order to leave comments, you need to log in
Hands do or in Interface Builder'e?
If in IB, then there should be no problems, you create a NavigationController with it, a ViewController will be created together with it, which is hooked to the NC as root, then just show segue on another VC from any button and everything will be with the Navigation Bar.
If by hand, then:
let vc = UIViewController()
let nav = UINavigationViewController(rootViewController: vc)
present(nav, animated: true)
There are no other options, everything works fine
In the interface, click VC. Editor->Embed In-> NavigationController And then we add our button to the topbar.
In the end, they refused that the problem was in the transition between storyboards. Forgot to mention that the question was not for Main.Storyboard . The fact is that the transition from one controller (from Main) to another (which is located in the new storyboard) was created programmatically using the present method . I have not yet understood why, but with such a transition, the navigation controller did not work linearly (if I may say so) and for each segue it simply presented a new controller. If we create a transition from one controller (in one storyboard) to another (in another, respectively) using the show method , then everything worked fine.
I will look for the reason.
Thanks everyone for the replies.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question