First, set the title
set in the previous controller that needs to display the return key :
1: "Logout", Style:UIBarButtonItemStyle.Plain, Target:nil, Action:nil)
Second, add the action when the return is performed:
You can try to fill in the event listener's handling at Target and action in the previous line of code, but it won't work.
Description of Backbarbuttonitem Discussion
When this navigation item is immediately below the top item on the stack, the navigation controller derives the back Butto N for the navigation bar from this navigation item. When the "is" is nil, the navigation item uses the value of the "the" to "create an" appropriate back button. If you want to specify a custom image or title for the Back button, you can assign a custom bar button item (with your Cus Tom Title or image) to the property instead. When configuring your Bar button item, does not assign a custom view to it; The navigation item ignores the custom views on the back bar button anyway.
Explains that Backbarbuttonitem can only customize the image and title, and cannot override the target or action, and the system ignores other related settings.
If you simply need to rewrite the action to do some other work, you need to customize a Leftbarbuttonitem because the system-defined Leftbarbuttonitem has a higher priority than Backbarbuttonitem, When Leftbarbuttonitem is present, the Backbarbuttonitem is automatically ignored and the purpose of rewriting the backbarbuttonitem is achieved.
Watch out.
Generally we take the item on the navigation controller to take this:
Navigationitem.backbaritem
If this means that the outermost layer of the two-level navigation bar is set to item, there is generally no such nesting.
NavigationController.navigationItem.backBarButtonItem
REF:
http://blog.csdn.net/dreamno23/article/details/21085783
Http://www.cnblogs.com/ihojin/p/change-backbarbuttonitem-text.html
Set the title and action of Backbarbuttonitem in iOS