UITableView Edit Mode Show Custom Buttons

此生再无相见时 提交于 2020-01-14 09:05:16

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4716324/uitableview-edit-mode-show-custom-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!