Override navigation controller back button - ios

I have a UIViewController called detailViewController that I push to from homeViewController.
In detailViewController there is a container that will display subview A, B and C.
If I tap the back button in the navigation bar, the navigation pops to homeViewController, as expected. I'd like to override the back button so that if the container is displaying subview B, the container updates to show subview A (and likewise, subview C goes to subview B). And if we're displaying subview A then pop back to homeViewController as expected.
Essentially, I need to be able to tap the back button but force the navigation to not pop to the previous view. Is that possible?
I know I could hide the back button and replace it with a custom bar button item but I don't want to do that. I want to keep the exact styling of the native back button.

Related

Pop view segue in Xcode

I have 2 UIViewControllers with their own navigation bars, but they're not embedded in a Navigation Controller. I want the bar button item of the first view to push the second view, and a bar button on the second view to pop the view, showing the first view underneath.
I've added a show segue from the first view to the second one in my storyboard but I can't find a pop segue when I try add a segue between the second view's bar button back to the first view. Here's what my storyboard looks like:
How would I make the back button on the second view pop itself to show the first view?

Swift - Remove View Controller from Navigation System

The best way that I can describe it is through and image, so i drew it out HERE. So, what happens is that in my table view, I press a button to add/edit information. When i am done, I press "Finish" at the bottom, which performs a simple segue back to the table view.
The Problem: Once back in the table view, the "back" button will now take me to the edit info page(which I just left) rather than the VC that came before it.
Is there any way to remove the Add/Edit info VC so that when I press "+" and "Finish" The back button will ignore the Add/Edit page?
Thank you for your help.
EDIT: . As you can see, when you press a button on the Table VC (lefT) it will take you to the right VC. Then, when you press finish at the bottom, it will perform a segue(no code, just a control-drag segue). The problem is still that the text message VC's back button will now direct back to the right VC, rather than the one preceding it (left)
I suppose you have a UITableView inside a UINavigationController since you have a back button, so:
User Tap Edit button: Push EditViewController in your UINavigationController
User Tap Finish from EditViewController: Save data, pop manually EditViewController and call reloadData of your UITableView
You would have to embed your complete sequence of view controllers in the navigation controller. This would maintain a stack of all the views that you would segue to. It will also give you a bcak button to go back to previous view. Alternatively, you can call the method popViewController() on navigation controller object to programmatically go to previous view. I hope that helps.

Back bar button item with right button

I have implemented a right item button in the navigation bar. I use the storyboard, no code. But now the back button is not displayed. What's the good way to show it again without boilerplate code ?
Thank you!
You can not see the back button on the rootViewController of the NavigationController
NavigationController automatically add the back button once you push some other ViewController to it.
It will display if you have not hides it explicitly.
If you have drag and drop the BarButtonItem as shown in the attached image, Just run the code and back button will automatically get added if it was not your RootViewController.
If it is RootViewController as displayed in images, try to push some ViewController on it, you will get the back button added.
If you add the left bar button item from Interface Builder, you will not get the back button displayed. Then you have to do it manually

Back button does not appear in viewcontroller

I wish to simply add a back button to the view controller, when accessed from a TableView in my app.
I have embedded the resulting ViewController within the navigation controller, and the back button is simply supposed to appear as documentation notes, but it does not...
Remove the UINavigationController between FriendsViewController and IndividualChatController.
When you push a new navigationController, it creates a new navigation stack with its own navigationBar and therefore you don't see a back button in the navigationBar

Right navigation item disappear when pushes JASidePanels

I am using the JASidePanels as submodule and I wanted to know if there is a way to keep the right icon on the navigation bar always visible and working.
For now I have my center panel which is a table view, and both left and right panels works.
But when I click a table view cell, it pushes a viewcontroller on it but the JASidePanel controls are lost... I cant slide it to the left to see my right panel.
Yes, I know that the left button will be replaced with the back button. This one is fine for me, I just care about the one on the right.
UINavigationController presents UIViewController (and subclasses). Each UIViewController is associated with an UINavigationItem that contains the information about the tool bar items and navigation bar items. This information is only used when that particular view controller is presented in a UINavigationController. If you want to put a button from viewController 1 in viewController 2, you need to assign the button to the UINavigationItem instance of viewController 2. Note that, if the action:target receiver for the button action is not viewController 1, you can easily create the UIBarButtonItem instance with the same characteristics in viewController1 for viewController2's UINavigationItem instance in viewController2's viewDidLoad method.

Resources