Single View Template add navigation - ios

So I started out an app by selecting the single view application template. I have added some more views using storyboard and everything was working good but I now wanted a button to take the user back to the first view using [ self.navigationController popToRootViewControllerAnimated:NO]; but the issue being the template started out as just a viewController. Is there a way to turn the first view into a navigation or root view to make this work or do I have to start all over in a page application template??

Insert a navigation controller in your storyboard before your root view controller.
Set the navigation controller as your initial view controller.
Set the navigation controller's root view controller to what was originally your first view controller.

Related

iOS Xcode: Editing Root View Controller

How to edit Root View Controller
Hello every one, I'm going crazy trying to find out how to switch a root controller with a table view inside, for a root controller with a normal view.
As you can see from the image I have the navigation controller pointing to a root view controller with a table view. Well I want that my navigation controller points to a root controller designed like the view controller in the right side.
How can I do that?
From the top of my head: Select the segue to the unwanted VC. Delete it. Ctrl-drag to the wanted controller from the navigation controller and set it as root.
You have to take the initial controller as navigation control, else you can not navigate from view controller as you did in your story board.
So select your view controller where a button is there(The left most in the story board). Then you can navigate to the screen.
So Your flow would be
Navigation controller (Make it Initial controller)
Connect the next view controller as root controller.
Then any controller you want can choose show/present type segue.
Hope it helps.

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.

Launching with one ViewController on navigation stack

I'm trying to achieve the effect similar to the native Mail application in iOS 7 where the initial view controller on launching already has the "Mailboxes" view controller in the back stack. Any ideas on how to accomplish this? Either Storyboard or programmatic would be fine.
In the app delegate didFinishLaunching I've tried creating an initial view controller (A) embedded in a navigation controller and then pushing a new view controller (B), and then setting that new view controller to be the window's root view controller but when B appears it doesn't have a navigation bar.
You shouldn't set that new view controller to be the window's root view controller, the navigation controller should be the window's root view controller. Just push that second controller with no animation, and that's all you should have to do.

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