Split View Controller and Segue Unwind - ios

I'm using UISplitViewController scheme for my project, and I put a UITableViewController in DetailedView. So there are two tables on left side (navigation) and right side (content).
Then I've created a new UIViewController and created a segue (Show Detail) from UITableViewController in DetailedView to navigate to this VC. I've also added and Unwind Segue for UIViewController to navigate back to UITableViewController in DetailedView.
But unwind segue doesn't works, because I'm presenting UIViewController segue as Show Detail segue. When I change segue to Modal Segue unwind works correctly, but I'm losing UISplitViewController (navigation master side disappears).
Do you have any ideas to make Unwind Segue work and return to Detailed View?

I'm using UISplitViewController scheme for my project, and I put a UITableViewController in DetailedView.
If that's literally true, it's wrong. The correct architecture, which is what you are given by the Master-Detail template, is:
UISplitViewController
UINavigationController [master]
UITableVieController
UINavigationController [detail]
SomeUIViewController
So your UITableViewController goes where I've written "SomeUIViewController". To navigate from there within the detail view, just push (or show). The user can now navigate back with the Back button, or you can pop in code.

Related

Why does the destination ViewController not get added to the navigation stack when segueing to it using 'push' style?

I have an app with 3 tabs.
In the 1st tab, there is button which leads to NoteViewController when tapped.
NoteViewController is a TableViewController with static cells; NoteViewController is embedded in its navigation controller.
My Goal: One of the static cells of NoteViewController (when tapped) needs to go to another TableVC in the 2nd tab which is also embedded its own navigation controller. For segue, I just use a segue from the storyboard and set the style to push.
Problem:
When segue seems to work fine, that TableVC doesnt become a part of the navigation controller of NoteViewController, thus it doesnt have automatic backward navigation... instead it just just opens up as if it was presented modally.
What could be the reason?
If the code is needed, I can post.

View Controller presented modaly but the segue is a Show Segue

My app start with a MainViewController that has an UINavigationController. If a show segue to another controller, if the new controller has a UINavigationController it seems to be presented modally, but if I remove the UINavigationController it works fine.
Is this normal iOS behavior?
how can I navigate in the controller if there isn't a UINavigationController anymore?
Every time you segue from your MainViewController (that has a navigationController) to a new ViewController, the new ViewController gets added to the MainViewController's NavigationController's stack.
If you segue to a new NavigationController from your MainViewController you create a new navigation stack and therefore iOS displays it like a modal.
To answer your question, you only need the 1 navigation controller on your MainViewController and all subsequent segues will be pushed onto the stack of that navigation controller. To get navigate back through the navigation stack to the MainViewController, have a look at navController.popViewController(animated: true).

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.

Xamarin.iOS / MonoTouch Storyboard Segue on UIViewController not found

The following situation in Xamarin.IOS/Monotouch applies:
I'm using two viewcontrollers, VCOne and VCTwo and I have assigned them two custom classes in XCode the Storyboard editor (MYVCOneClass and MyVCTwoClass).
Then I drag a segue from VCOne (from the viewcontroller in the left listing) to the VCTwo viewcontroller instance in the editor part and select "Push".
I name the segue "OneToTwoSegue".
My question
When I perform the following call from a button click eventhandler in the VCOne class:
this.performSegue("OneToTwoSegue", this);
I get a runtime error saying that the OneToTwoSegue cannot be found on the MyVCOneClass object.
Does anyone know why i cannot call this segue from code like this? I know i've seen segues working when i link them to cell's, buttons and alike...
If you are doing a "push" segue, your first view controller needs to be the root view controller of a UINavigationController.
So in your storyboard, drag and drop a UINavigationController, delete the tableview and the ViewController that's attached by default, and then make VCOne the root view controller (the same way you would make a segue - hold control and drag from the UINavigationController to the UIViewController and then click root view controller.
Your Segue should work fine after. Just make sure that the UINavigationController is set as the first screen (that little arrow that points to the left should be moved from VCOne to the UINavigationController)
EDIT:
I have uploaded a screenshot of a sample storyboard I created to demonstrate this to you.
VCOne is the root view controller of the Navigation Controller. And there is a segue from VCOne to VCTwo called OneToTwoSegue. With this, your code on your button click will work perfectly.

Push segue from a view controller controlled by UITabBarController

Let's assume that a first view controller is connected with a UITabBarController and I want to make a push segue to the second view controller from this first view controller.
From my googling, it seems that a modal segue from a view controller connected with a UITabBarController hides the bottom tab bar, while a push segue doesn't.
However, my push segue is also hiding my tab bar in the second view controller. I have overridden prepareForSegue method in the first view controller.
Below are images of my storybard and the simulator. Anyone has an idea why this is the case? Thank you in advance for your helps.
Your trouble is because your tabViewController is embedded in the navigation stack that you initialise with your login screen.
you need to rearrange things so that each of your tab bar controller tabs opens to a new navigation stack.
What I suggest
your loginscreen should navigate to your tab bar controller with a modal/presenting segue, not a push segue. Remove the navController that encloses the loginscreen, you don't need it (well, even if you keep it, don't use a push segue, use a modal segue, and you won't then be referring back to that navController's viewController stack from inside your tab bar).
embed each of the first viewControllers in your tabViewCOntroller inside a separate navController.
Now you can push segue within your tabViewController's tabs.

Resources