Sunday, 29 September 2013

Replace navigation bar cancel button with back button

Replace navigation bar cancel button with back button

I have a table view controller embedded in a navigation controller. The
table cells are all static and selecting any of them will segue to another
table view. When segue happened, the navigation bar shows 'Cancel' button
for the new view, instead of 'Back' button.
I could add a back button in code like
self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonSystemItemCancel
target:nil
action:nil];
self.navigationItem.leftBarButtonItem =
self.navigationItem.backBarButtonItem;
But then the back button would be a rectangle shape, not the default back
button shape which has an angle on the left edge. How to simply change the
cancel button to a system back button?

No comments:

Post a Comment