Search code examples
iosswiftuinavigationcontrolleruistoryboardsegue

Custom segue with Navigation Controller to another storyboard swift


I have navigationController embedded VC(Viewcontroller) in storyboard 1 which is connected to storyboard reference of storyboard 2.

Now, I have VC2 which is again NavController Embedded in storyboard 2. I am performing the following code :

let storyboard = UIStoryboard(name: "Settings", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "setEdit") as? EditProfile
navigationController?.pushViewController(vc!, animated: true)

settings is storyboard 2, setEdit is ID from navigationController of the destination VC.

When I execute this code, It doesnt perform the presentation of new controller. Also, I have a custom segue class that transitions VCs from Right to Left.

when I use :

present(vc!, animated: true, completion: nil)

It just pushes the VC from bottom to top.

Now I am totally out of Ideas.

My query is:

How can I exactly implement custom segue from one storyboard to another, having navigation bar at the top.


Solution

  • When you use UINavigationController the transition is showed as you said from right to left (push), when you present a view controller modally the presentation style and the transition style are different. Now you cannot connect two navigation controllers, so I suggest to connect directly the controller in the settings storyboard without embedding it in another navigation controller. In settings storyboard you have to set your EditProfileVC as initial view controller and check its identifier and then you can push it from your first storyboard.