Overriding Back Verbiage on Navigation Bar - swift

In Swift, how does one override default behavior for the back button that comes with the navigation bar. Currently, the back button behavior is to provide the left-facing chevron and then the title of the previous tableview in the stack (if it will fit on the nav bar). However, I prefer that it always say "Back" regardless of the whether the previous tableview's title will fit on the bar or not. As illustration:
In the pic above I'd like for the "Genre Fiction" to be replaced with "Back".

in storyboard, go to the view controller that you are wanting to go back to. click "navigation item" in the view hierarchy, and go to the inspector/attributes panel and change the "back button" entry to just "Back"

Related

Can't customize back button on UINavigationViewController

I've got a set of views embedded in a navigation view controller.
The way it works is that a button in the first viewController (embedded already in navVC) transitions w/"Show (e.g. Push)" which causes a "< Cancel" button text to appear in the top left.
Then I tap a cell which does another "Show (e.g. Push)" transition to a third vc which show "< Back" button.
I'm happy with the way the "< Back" button appears, but I want to remove the "<" from the "< Cancel" button so it just says "Cancel" with no arrow.
How can I override the back button to just show the title text, and also not pass that behavior along to further controllers in the series?"
Given the behavior you are describing, it sounds like it would make more sense to present the 2nd view controller as a modal in its own navigation controller. Then you can add Save and Cancel (or whatever you need) UIBarButtonItem buttons to the leftBarButtonItem and rightBarButtonItem of the 2nd view controller's navigationItem. The 3rd view controller can still be pushed as needed.
If you really do want to simply push the 2nd view controller but replace the standard back button then in the 2nd view controller you can set its navigationItem.leftBarButtonItem to a new UIBarButtonItem as needed. The left bar button item will be shown in place of the default back button.

Navigation bar object in xcode 5 not showing back button and has no functionality

I have been trying to properly setup a navigation bar in one of my View Controllers for an hour now and have not found any working solutions.
I control-clicked on a button on my app's initial view controller(1st VC) and dragged to another view controller(2nd VC) and selected "modal" as the action segue.
I then added a navigation bar item to my 2nd view controller.
When I run my app on my iPhone, I can tap on the button on my app's initial screen and it will take me to my 2nd VC, and the 2nd VC does display the navigation bar, but the navigation bar does not have the default iOS 7 back arrow to let me go back to the app's initial VC.
I was under the impression that this could be setup exactly like I did above and that the back button functionality would be included by default.
Am I completely lost? Do I need to further customize navigation bar programmatically or with a tick box in the attributes inspector? Is "modal" the wrong action segue option?
I basically just want to have navigation bars at the top of a couple of my VC's so that the user can easily get back to the app's initial screen.
Thanks for the help.
Since you are presenting your second screen (2nd VC) as MODAL from your first screen (1st VC), you will not see the back arrow button on navigation bar. Your understanding about back button works for Navigation view controllers (push segue). For MODAL you need to put a cancel button on second VC's Nav bar and put a dismiss action for that.

Unhide UINavigationBar LIKE in the Email App

I have a View Controller where I perform a "search as you type". When I press on the SearchBar, hide the Navigation Bar, animated and I also show the scope buttons for my SearchBar. The problem is that when I press on a cell to push a new View Controller the Navigation Bar stays hidden. I KNOW I can set it unhidden, but it will animate from the top. I want to do something similar like in the Email app, when I press on a new cell, a new View Controller is pushed, and the Navigation Bar is animated from the right, like it belongs with the pushed View Controller. How can I make this happen?
Thank you.
Cosmin
Use the UISearchDisplayController to handle the search bar. The behavior you describe is the default behavior.

Invisible back button when view controller pushed onto navigation controller

I'm using a navigation controller to drill into a detail view when a cell is tapped. When I push my view controller onto the navigation controllers stack, I expect to see a back button that I can tap to pop the previous view off the stack.
The issue is that the back button isn't visible, but when tapping where it should be returns me to the previous view. What's the problem?
Ensure you have set a title for the master view - for example in viewDidLoad add this -
self.title = #"The Title";
Weirdly, if there is no title for the parent view controller on the stack, rather than show an empty back button, the iPhone will not display a button but will allow taps on the area where it should be.
This bugged me for a long time!
At least as of iPhone 3.0, you can also avoid the dreaded invisible back button by setting a title on the root controller's navigation item in your main window's nib (MainWindow.xib in wizard-generated projects).
Lets see if this helps you.
I had the same issue where I used a navigation based application and set up my search, rotation etc..
BUT, when I clicked on the table cell I was directed to the next view but that view did not have a back button present.
I tried to add a title to the back button but that did not work so this is what I did.
I opened the mainWindow.xib file and added a Bar Button Item to the group of other items inisde the window (where the file's owner is located). I then assigned an image to the button (you can add text here if you want).
Then I clicked on the Navigation Item and hit command 2 to open up the Navigation item connections
and chose the back bar button item and dragged it to the bar button item I wanted to use for my back button. And there you have it.

How do I support the touch of the navigation bar label?

I have an editor that I am making, and I need a way of editing the document's title. I was considering touching the title of the navigation item and have a custom view appear.
I did this in an initial version of the application with a button bar item (and target/action), but I cannot seem to find a way to do it with the managed navigation bar.
The alternative I was considering was putting another bar at the bottom with an item to do just that, but it doesn't seem like the best design if I don't need to do it, as it takes away from viewing space.
You can set the titleView property of the view controller's navigationItem to a UIButton of type Custom. Then wire the button up to a method on the view controller. Now when the user taps the title, it'll fire the method on your controller.