Reputation: 3
I think this is a really simple task, but I just can't get it.I have a viewcontroller on a storyboard that isn't very complicated. Here's what I want to do:
I want the navigation bar of my view controller to have essentially 3 buttons, but only show two at a time. One button is a simple uibarbuttonitem that is always on the right side. Another is a backbuttonitem that's always on the left side. Lastly I want a save button to be on the left side also. I want this save button to appear in place of the back button only when a uitextview is being edited and then have the back button appear again in place of the save button when the textview is done being edited or when the save button is clicked.
Anyone know the easy way to do this? Do I do it through the storyboard, or should it be done completely programmatically?
Upvotes: 0
Views: 310
Reputation: 318794
I don't know about storyboards but in code this is trivial. To show the "save" button on left you create the button and call:
self.navigationItem.leftBarButtonItem = saveButton;
When you wish to remove the "save" button and show the back button again, you simply do:
self.navigationItem.leftBarButtonItem = nil;
This code goes in your view controller (self) and it assumes the view controller has been added to a navigation controller.
Upvotes: 2