How to push a view controller programmatically from Detail view controller - ios

My app has a split view controller as root with master detail view. I'm doing this programmatically without using storyboards. I want to push a new view controller from a button in detail view and close the split view. When I tried, it opened inside the detail view. self.navigationController?.pushViewController(mainView, animated: true)
But I want it to open full screen and have a back button to goto the split view. How can I do that?

I think you need either present it Modally or change the rootViewController in corresponding to your action.

Related

How to hide the master view if navigate to new view controller from detail view controller

I want to hide view if user click on button in details view controller to push new VC
I tried this line work when push new view put when pop view the master never appear
self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.primaryHidden
How about setting the preferredDisplayMode back to normal when you pop the detail view controller?

Navigation bar is empty, created from storyboard

This is my story board:
Whenever I jump to a view controller embedded in navigation controller, the navigation bar is shown but empty, why?
The sequence I created it is:
connect buttons with destination view controllers
embed destination view controllers in navigation view controller
And the segue I use is present modally - cross dissolve.
The First root controllers of a navigation controller won't have any Back button attached to its navigation bar. You should add an additional View Controller next to any root View Controller of Navigation Controller with Push Segue ( or Show Segue for newer IOS ) to navigate between them.
I tested different segue transition methods with test projects, the answer I got is: if you are transitioning by presenting it modally, you don't get the back button, you only get it by push.

Swift Using a Back Button on Two View Controllers

My second view controller is a table view controller. I wish to segue to a first view controller with a back button. I have tried using Editor>Embed In>Navigation Controller. It places a navigation bar on the top where I can place an Item (Back button) on it, and after segueing it back to my first view controller, it becomes very screwy (it shows two navigation bars on top of each other). Is there a better/easier way to move back to my first view controller?
if u want to use navigation controller to manage ur push&pop stuff, just make sure:
navigation controller is ur initial view controller
ur first view controller is the root view controller of navigation controller
set an unique identifier to second view controller
leave ur second view controller alone without any link to other vc
like this
then push like this
let secondVC = (self.storyboard?.instantiateViewControllerWithIdentifier("identifier"))! as! urVC
secondVC.title = "second view controller"
self.navigationController?.pushViewController(secondVC, animated: true)
and pop like this
self.navigationController?.popViewControllerAnimated(true)
alternatively, u can use unwind segue following this tutorial

Showing a UISplitViewController inside a pop over

I'm wanting to create a UI where I have a popover that comes from a button that and contains a split view UI with two table view controllers side by side.
The storyboard I have now has a normal page with a button, the button has a popover segue to a split view controller.
The split view controller has a master relationship to a navigation controller which has a root view controller of a table view controller.
The split view controller has a detail view controller to another navigation controller which again has a root view controller of a table view controller.
When I launch the pop up it only ever displays the master controller, not the two side by side.
UISplitViewCpntroller can only be the root view of an app - as such, you cannot put them in a UIPopover or any other non-root view.
You would have to create your own UISplitViewCpntroller type view (or look for some open source code).

Initial View Controller on top level of hierarchy loses NavigationBar

I have a hierarchy of 3 TableViewControllers embeded in Navigation Controller and I need to launch on the most detailed level on the top of the hierarchy. If I change 'Is Initial View Controller' in storyboard to the last detailed TableViewController, my app launches with the selected TVC, but with no NavigationBar. How can I launch on the desired level of hierarchy and keep the Navigation Controller managing the stack of views?
Thank you.
You're telling the storyboard that your third view controller is the root view controller--it has no navigation bar. If you want the navigation controller present as the root view controller then you need to make it the initial view controller, then change the navigation's root to your third view controller.
eg:
initial-->[navigation controller]-->[third VC] [first VC]-->[second VC] (keep these around if you want... just disconnect them from the navigation controller)
You would have to select the ViewController that you want as initial and embed it into a NavigationController, and then add all of the other views after that using push segues.
But why do that? Why not just have the first viewcontroller display the data that you will have in the third view controller? you will end up with the same results.
You should also check out this.

Resources