Rename the standard "edit" button as a table

I managed (with a lot of trial and error) that my tablet only provided reordering functions, i.e. my table is visible for editing, but does not display “delete icons” and does not indent lines when I click on the edit button.

Now I would like the button to read "sort" instead of "edit".

I naively tried this:

self.navigationItem.leftBarButtonItem = self.editButtonItem; self.navigationItem.leftBarButtonItem.title = @"Sort"; 

which works only once, i.e. it is correctly marked as "Sort", after clicking it is renamed to "Finish", but then - as expected - is renamed to "Edit".

To fix this, I expanded my own button on the navigation bar. This solution works - I can get the button for controlling the editing mode of the table, reload the data when changing, rename myself, etc., but I can not make it "remain selected", that is, the default behavior of the "Change" button in the form of a table.

Now my question is:

a) Is there a way to rename (and save it renamed, for example, through a callback) the standard "Change" button?

or

b) Is there a way to make the button behave “modally”, i.e. stay selected like the standard "edit" button?

Thanks for any idea you may have.

+2
iphone uitableview
source share
1 answer

You can put your changes into the - (void) setEditing:(BOOL)editing animated:(BOOL)animated method in your view controller.

 - (void) setEditing:(BOOL)editing animated:(BOOL)animated { //Do super before, it will change the name of the editing button [super setEditing:editing animated:animated]; if (editing) { self.navigationItem.leftBarButtonItem.title = @"Done"; self.navigationItem.leftBarButtonItem.style = UIBarButtonItemStyleDone; } else { self.navigationItem.leftBarButtonItem.title = @"Sort"; self.navigationItem.leftBarButtonItem.style = UIBarButtonItemStyleBordered; } } 
+6
source share

All Articles