Popping View Controller when not using a Navigation Controller? - ios

I have searched around and all cases of using the pop to return to a previous view controller seem to be based around using a navigation controller, I am using a tab bar controller and have no real need to the navigation controller and so havent implemented it.
I load this detailed view controller via a segue based on rowindex selected in a list controller and just need to close it when they are done reading with a close button.
Is there still a method that can be used to pop a view controller without it all being housed in a navigation controllers unnecessarily?

Why don't you use a Storyboard and use an Unwind Segue to go back to the prev. View? Take a look at this Unwind Segue, hope will help you.

Related

Why is the tab bar disappearing?

My current setup of viewcontrollers are:
tab view > navigation controller > table view controller > navigation view controller > cell details. Please see
The current setup of viewcontrollers
I used to have:
tab view > navigation controller > table view controller > cell details
and then everything was fine.
The issue is that I need a custom action to happen when the user presses the back button, and to do this i added a nav controller between the "table view" and the "cell details". And thats when the tab bar disappeared. I understand this seems to be "normal" behaviour, but that don´t help me much. Please help.
The code that segues to the detail view controller. (I use the storyboard, so light on code for these things)
#IBAction func add(sender: AnyObject) {
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("TableViewToDetailView", sender: self)
}
It happens when hideTabBarOnPush property is true(in code) or Hide Bottom Bar on Push is checked on storyboard for the controller you are pushing.
I had a similar problem and the right question was kind of hard to ask. using Tsb Bar Controllers with Navigation Controllers and View Controllers os too tricky and certain things a re not allowed and there is a lot of terminology, and, there are many different types of segues,and there are many different kinds of consequences for doing certain things.
I found the correct procedure (answer) in the second part of this two part series:
Storyboards Tutorial for iOS: Part 1
Storyboards Tutorial for iOS: Part 2
Summary of the procedure:
Embed the source and destination View Controllers in Navigation Controllers, then create unwind segues (methods with the signature#IBAction func methodname(_ segue:)) in the source view controller. Then, from the destination View Controller, control-click from the navigation bar button (or any view required to trigger a return to the first view controller) to the Exit object above the view controller then pick the correct action name from the popup menu. The unwind segue will be accessible from the Document Outline and can be given an identifier to use in prepare(for:sender:) in case data needs to be sent to the from the destination view controller. Also, the segue from the first view Controller to the second navigation controller must be modal.
A similar issue I met although maybe not quite the same as yours but hope it may help. When view controller A presents view controller B, the hidesBottomBarWhenPushed property of B could be overridden by the hidesBottomBarWhenPushed property of A. I fixed it by setting B's modal style.

Why use Navigation Controller as 1st item in storyboard

Sorry if this is a noob question, I'm starting to learn iOS programming.
As I see im many tutorials and examples, the 1st item in storyboard is almost always a Navigation Controller, like in the image below:
My question is: what is the reason to always put a Navigation Controller as the first view controller? Like in the image above, I think that can remove the Navigation Controller and set the Test Table View Controller as the first view controller, so why need a Navigation Controller there?
Because the navigation controller is what allows tapping a table cell to do a push segue to the next view controller.
Using Navigation Controller could let you make the push segue, It allows you to manage your views in a stack. It's OK to remove the Navigation controller, but you must use another segue to transform controllers.

How to design a mechanism to manage viewcontrollers transitions, like route

I want to design a routing mechanism for management view controller transitions in objective-c.
Two view controllers, without reference to the other side of the pointer, the transition is completely controlled by the route.
How to achieve the route?
Thanks for your help.
I hope you think like this.
Route = Segue (In Xcode)
Take Two View controller
Make 1st Embed in Navigation controller (Which is must be initial View Controller)
Put One Button in 1st VC
Press Ctrl + Drag Mouse from button to 2nd VC (One popup will be show, then select Push)
Run Project
Press Button
Lol
You can use Storyboard's segues. Create view controllers and segues between them. You can use Push Segue or Model Segue. Push Segue will let you pop next view controller too, and you will have to embed your first view controller into navigation controller. For Model Segue, you can move from one view controller to another but to return to previous view controller, you will have to create another segue.
I think I find the approach to answer this question。 Here is the similar project.

how to make a page accessible from every other page in my app and able to unwind to where the segue comes from

I am trying to create an on-top structure where user can go to a general page G from any other pages with a special gesture and go back to the page where s/he comes from.
Is there a way to do this while not implementing a segue and an unwind segue from every other page to page G?
Thank you!
Yes, you can do this without having a segue from each controller, but it depends on how your controller hierarchy is set up. If for instance, you have a navigation controller, and all your view controllers are pushed onto its stack, you can create one segue from the navigation controller to the one you want to go to from any of your other view controllers. You could also do this if your other controllers are embedded in a tab bar controller (the tab bar controller would present the common controller).

Difference between navigation controller and viewcontroller?

Difference between navigation controller and viewcontroller?
I mean how can we decide when to use navigation controller or a normal view controller?
Just my two cents:
A UIViewController represents a single view and you can put buttons in this view controller to segue to another UIViewController. If you want to segue back to the first UIViewController, you will have to worry about putting a button in the second view controller that leads back to the first. If you are drilling down into view controllers, this can be tedious having to remember to give the user a way back to a previous view controller.
A UINavigationController does a lot of this tedious work for you. As mentioned, it contains a stack of UIViewControllers. It will create a navigation bar at the top that will allow you to easily go back up the hierarchy of view controllers.
In short, if you have a hierarchy of view controllers that you want the user to easily navigate around, inbed your UIViewControllers into a UINavigation controller.
UINavigation Controller is a combination of 2 or more view controllers,those are connected through "segue" feature of "Ios". Benefit of using Navigation Controller is that we can navigate between different screens easily with default "Back" button on each screen . We don't need to give any individual button to move back onto previous screen.
Whereas a ViewController provides a single screen & we can connect more screen using "segue" but we also have to design a "Back" button to navigate onto previous screen.
We should use Navigation Controller , in case where one option resides into another one.Like in an iPhone settings ->Mobile Data Options->Voice->4G or 3G or 2G. It's a hierarchy of menus so here navigation Controller is better option than using UIController.
We should use UiController with "segue " , in case where
we have to choose one option among multiple.Like -
Photos ->There are many folders in which , any one is selected, that are Favourites or People or Places .
Here's a very brief, high-level overview.
Whereas a UIViewController can be thought of as representing a single 'screen', UINavigationController, as the name implies, is used as a means of being able to navigate multiple 'screens'.
From the documentation:
The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This navigation interface makes it possible to present your data efficiently and makes it easier for the user to navigate that content. You generally use this class as-is but in iOS 6 and later you may subclass to customize the class behavior.
Please see the rest of the UINavigationController documentation here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html
Okay, Thank you everyone for helping me to find out a clear answer on this.
Navigation Controller consists of navigation bar and tool bar to move in and out from view controllers present in navigation stack.Therefore there can be many view controllers in Navigation Controller.
In view controller we don't have this facility and it represents a single screen view.
Please correct me If I am wrong.
See the Navigation Controller discussion in the View Controller Catalog.
Bottom line, a navigation controller actually is a view controller, but it just happens to be one that presents and navigates between other view controllers.

Resources