Swift StoryBoard Reference segue to Navigation controller not Root - ios

Is there a way to use storyboard reference segue to a controller which is the second controller inside a navigation controller?
To be more specific:
I have a cameraViewController in storyboard A.
I would like to create a segue (with a storyboard reference) to storyboard B.
In storyboard B i have a navigation controller with two controller.
The segue should be from storyboard A (cameraViewController) to storyboard B (SecondViewController).
If in the reference I use the StoryBoard reference of the controller the navigation bar is not displayed. And if I use the Storyboard ID of the navigatin controller, well the segue is to root controller.
Thank you.

In your Storyboard, a particular View Controller can be linked to more than one navigation structure.
So, you can have Controller B as part of more than one Navigation Controller.
In Storyboard "SB_A" create a segue to Storyboard "SB_B", but instead of segueing to the "default" VC in SB_B, segue to the VC identified as "FromSBA" - in this case, "FromSBA" is a 2nd Navigation Controller inside SB_B, whose root VC is Controller B.

Related

How to connect a Navigation Controller in one storyboard to View Controllers in another storyboard?

Here is my Navigation controller that has one View Controller in the stack, but I have another storyboard with Viewcontrollers I want to add to the stack. I have the Views separated in order to better organize my Views and to have less views per Storyboard. How do I add Views from the referenced storyboard to the Navigation controller shown?
Right now I have the reference pointing to another Navigation controller in the second storyboard, but I wouldn't have a back arrow to the viewcontroller in the first Navigation Controller.
In the Storyboard A where you have a navigation controller add a Segue to Storyboard B (Settings) and make sure that you also write the View controller ID (MyViewControler) that you like from within Storyboard B in the Referenced ID
in Storyboard B (Settings) add a navigation controller and set the root view controller to the one that you like (MyViewControler) this navigation will be use only show the UI as it will be in the navigation controller from Storyboard A and will not be part of the navigation stack, This is because you add Referenced ID !!!

Segue from one view controller embedded within UINavigationController to another UINavigationController

I have a UINavigationController as my root controller, but then I segue from one view controller to another UINavigationController.
But when segueing from one view controller which is embedded within a UINavigationController to another UINavigationController the push segue comes from the bottom, presuming it is segueing as a popover. I tried using a show detail segue but still not luck.
Why is this occurring and how can I segue from one to the other using a push/replace segue ?
PS: Is this happening because the UINavigationControllers conflict and overrides the segue as a popover ? The reason I am using two separate navigation controllers is because the style from the previous view overrides the style of the detail view, i posted a separate question about that Cannot change style of UINavigationBar when using scrollViewDidScroll on separate View Controller
Push segue occurs only within one navigation controller. It's how it implements 'show' type segue. Making 'show' segue from navigation controller to another navigation controller is not what Xcode drawing tool considered as 'pushing'. It interprets it as popover by default.

How to navigate a child view controller from other child view controller in objective c

I want to navigate to a view controller from another controller. Both view controllers are child of root view controller of navigation view controller. Now I want to navigate to a second view controller from the first view controller and same as first view controller from second view controller using navigation view controller. How to do that?
The Storyboard image is as follows :
you can just drag a segue from child1's button to child2, and child2's button to child1, though the storyboard will look ugly, but it works. or you can just use
[self.navigationController pushViewController:child2 animated:YES];
You can setup NavigationController with rootViewController is Controller1
when navigation to Controller2 (from Viewcontroller1) just push viewController2 to navigation controller.
when navigation to Controller1 (from Viewcontroller2) just pop viewController2 from navigation controller (or pop to viewController1).
Make another segue from first View Controller to Second View Controller & give it Push navigation.Also give identifier to segue like 'ABCSegue'. Then On the action of Button write
[self performSegueWithIdentifier:#"ABCSegue" sender:nil];
Do same for navigate from second view controller to first view controller.
Hope this will help you.

Unwind segue in multiple storyboards environment

My app has more than two storyboards. In storyboard A, it has navigation view controller, root view controller and several view controllers.
It also has an unwind segue, like returnToTopScreen.
Storyboard B has several view controllers. At execution, all VC in B is on the navigation stack.
My question is,
Can unwind segue work for inter storyboards unwinding?
According to my trial, Xcode6.2 allows a UIbutton in VC of storyboard B to connect with an unwind segue in storyboard A. But it does not work.
Yes, you can unwind between storyboards as long as you got to the controller in the second storyboard by pushing or presenting from one of the controllers in the sequence that leads back to the one you want to unwind to. I tested this in a setup where the main storyboard had a navigation controller with its root view controller, and one other controller that was pushed to from the root. In that controller, I instantiated the controller in the second storyboard, and either pushed or presented it. An unwind from that controller in the second storyboard successfully went back to the root of the navigation controller.

UINavigationController shows black screen after pushing a view

I have a storyboard application with a navigation controller an two views controllers ('A', 'B').
In the Storyboard file:
Navigationcontroller is the initial view controller. view controller 'A' is connected to the Navigationcontroller as rootcontroller. View controller 'B' is in storyboard but not connected to any view controller.
when i programmatically try to push view controller 'B' onto the navigationcontroller from inside view controller 'A' with:
B *controllerB = [[B alloc] init];
[self.navigationController pushViewController:controllerB animated:YES];
all i get is a transition to a black screen.
i checked the navigationController property in view controller A at runtime and it´s not nil.
I do not instantiate the navigationController by myself, I let storyboard do the work (maybe that´s the problem). But I think it should be possible to "manually" push view controller to a navigation controller created by storyboard.
When I connect a segue from a button to 'B' in storyboard everything works fine.
Only programmatically it does not work, only shows a black screen inside the navigationcontroller.
Maybe someone could help me with this issue.
I haven't used storyboards yet so this answer is from a glance at the docs. It looks like you can't alloc/init a view controller from a storyboard. You need to use the instantiateViewControllerWithIdentifier: method of your UIStoryboard instance and then you can push the controller.
The accepted answer didn't work for me. I was already using instantiateViewControllerWithIdentifier to navigate to view controller in different storyboard. I am using xcode7.2 and Swift.
I am navigating from storyboard1, some view controller's button action.
Destination is to initial Navigation controller of Storyboard2.
Still I get black screen.
The problem was storyboard2's Navigation controller linked to 1st view controller was linked via show.
Solution:
Delete the link between Nav controller and 1st view controller. Now link it using root view controller. (Ctrl+Click on Navigation controller and drag it to the View controller and Select the option "root view controller")

Resources