Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView Edit Mode Show Custom Buttons

I know that people hate vague questions here so I just need a yes or no answer. I have a tableView and I want people to be able to edit the contents of the table.

I like the setEditing method but I don't want the button to say Delete - I would prefer Remove and there are times where I want to display more than one button and hide the delete button. I just need to know if this is possible.

I am ready to give up on using the standard edit and delete buttons and just make my own but before I did I wanted to know what was possible.

Thanks very much Cheryl

like image 348
Cheryl Avatar asked Jan 17 '11 18:01

Cheryl


2 Answers

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html

Just implement this method on your UITableViewDelegate:

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath

Then you can set the title for that delete button and make it say "Remove" instead.

like image 79
Kenny Wyland Avatar answered Oct 04 '22 11:10

Kenny Wyland


As Kenny pointed out, you can use the tableView:titleForDeleteConfirmationButtonForRowAtIndexPath: method to change the title of the delete button. If you want to use a different button altogether, use UITableViewCell's editingAccessoryView property to change the view shown in editing mode.

like image 40
ughoavgfhw Avatar answered Oct 04 '22 12:10

ughoavgfhw