Multiple Navigation Controllers with Back Buttons in Swift - ios

I'm making an application that has:
Navigation Controller -> View Controller -> Navigation Controller -> View Controller -> Navigation Controller -> View Controller.
This is making it so that there's no back button on the second view controller, only the third one, and I can't get it to appear. I'm fairly new to iOS and simply want to have a path of view controllers that the user can navigate down and back. Is there a way to add the back button to the second view controller's nav bar? Is there a better way to do this? Is it problematic to just create buttons at the top of views that perform segues?
I found some Objective-C solutions but couldn't find anything in Swift. Thanks for your help!

Remove all the navigation controllers except the first one.Your app must be like this..
Navigation Controller -> View Controller -> View Controller -> View
Controller.
Call segue to move to the other controller .. Just dismiss your controller if you have modally showed them on back button pressed or pop them from
navigationController
if you have pushed them.
Now for Back, you can do it in multiple ways. One of them is, add a view on the top of your controller, add a button on it and implement an action when someone taped it..
I hope you will got that ...

Related

Change View Controller in Tab Bar Controller (Swift)

A little background: My app pops a View Controller that has questions. When the person has answered the question, they swipe and View Controller is presented again, this time with new questions (so it is View Controller with question set 1 -> swipe -> (same) View Controller with question set 2).
This works fine when I do not have View Controller embedded in a Tab Bar Controller. However, when it is embedded in a Tab Bar Controller and I swipe, the View Controller is presented but the Tab Bar Controller is no longer there.
I want the tab bar to remain at the bottom of the screen but I want the View Controller to change upon swiping
func swipeGesture() {
// gesture stuff in here
self.present(ViewController(), animated: true)
}
In Tabbar Controller put a navigation controller. Above the same you can push as much as view controllers of same type or that of different types.
It will work.

Popping View Controller when not using a Navigation Controller?

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.

Adding a Back Button on A Table View Controller

I am interested in implementing a back button to segue to a previous view controller. I have tried to embed a navigation bar onto the the top of the table view controller but the issue is when I do segue back to the first view controller, by default, Xcode keeps the navigation bar with a back button to go back to the table view controller. Is there a simpler way to implement a segue to go back to the first VC without the navigation bar remaining?
I'm not too sure if this works, but embed your view controllers including the first one inside the navigation controller. That would make all your view controllers with navigation bar above.
On the main view controller (the one you do not want to have the navigation bar), add the line of code inside your viewDidLoad method.
Swift 3:
self.navigationController?.navigationBar.isHidden = true
I found an easy way. On your TableViewController, drag a UIview to the top of the view controller and itll let you insert the view. From there just add your back button
Just assign your "Back" UIBarButtonItem to this method and it should work.
#IBAction func backButtonPressed(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
}
Sounds like a few problems
1) How are you navigating from the first view controller? Is it with Show (Push) if not, you are replacing the first view controller in your stack.
2) Based on your problem, make sure your first view controller is not embedded in a navigation controller
3) As Dylan mentioned, you need to hook your back button to remove the current view controller to return to the first one
4) Extension of (3), how are you segueing back to the first view controller? If you are explicitly navigating to first view controller with your back button handler, it's not actually going back but rather forward and keep the navigation bar.

How to show a view controller using a navigation controller segue, including back segue (Swift)

I have to view controller, One has a button and the other is embed in a navigation controller. I Don't know how to make a proper segue to that second view controller including a back (unwind) segue. That is in swift.
You're going to use a navigation controller. Go and select your view in the storyboard, and select Editor -> Embed In -> Navigation Controller. Do the same for the second view. Now, add a button in the first view that connect to the second view on a click. Make sure when you drag and drop that it's a push segue.
Voila! You should now have your navigation controller working.

Segue-ing to Embedded view controller

I have have a view controller that is embedded in a UINavigationController and I want to segue to another view controller that is also embedded in a different UINavigationController. If I try to use a push segue, I get an error saying that I can't push a UINavigationController. However, I don't think using a modal segue is appropriate. How should I go about this?
How should I go about this?
You should use a single navigation controller.
the problem is that I want different bar button items for each view controller and they won't change
Each view controller can set up the bar buttons however it likes. Take a look at UINavigationItem. Each view controller has a navigation item, and the navigation item has various properties such as leftBarButtonItems and rightBarButtonItems that you can use to set the buttons.

Resources