Skip to content

Instantly share code, notes, and snippets.

@thornpig
Created January 20, 2016 23:24
Show Gist options
  • Save thornpig/01e63fad50e848cb2f4b to your computer and use it in GitHub Desktop.
Save thornpig/01e63fad50e848cb2f4b to your computer and use it in GitHub Desktop.
To set the back button title for a view controller without changing it's title
To set the back button title for a view controller without changing it's title you use:
Objective-C:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:self.navigationItem.backBarButtonItem.style target:nil action:nil];
Swift:
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil)
To be clear, this is done on the view controller that you would see if you hit the back button.
i.e. instead of seeing '< Settings' you want to just see '<' then on your SettingsViewController you would put this in your init.
Then you don't get any of the problems of the title not showing when you're looking at the view controller itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment