The following code will set the back button title of the current UINavigationItem:
Updated to fix memory leak. (Thanks Sam!)
|
|
The target:
and action:
parameters are definitely ignored (replaced by the default back button behavior) and the style also seems to be ignored because the back button retains its pointed left side.
This next block of code looks like it should do the same thing but does not work:
self.navigationItem.backBarButtonItem.title = @"Back";
This is because the back button is “owned” by the previous view on the stack (as pointed out in this thread). In other words, the setBackBarButtonItem
method should be called on the view that the user is navigating away from, rather than the view above which this button is actually displayed.
UINavigationItem on Apple Developer Docs
Comments