How do I add properties for the "back button" in the navigation bar? The button links from detail view and back to the master view. I can't find any code for the back button, and the button is hidden in storyboard view.
This back button is added automatically by the UINavigationController in iOS, you can customize some things like the name, e.g. if you want to change the title or remove it totally while keeping the icon, you can use the below code:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Custom Title"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
Leave the title @"" if you want no text; also you can customize the behavior of the button by adding your own method like this:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Custom Title"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(backButtonEvent)];
- (void)backButtonEvent {
// Your code here
}
Be careful, this should be added to viewDidLoad in the first controller, not the second one.