开发者

iPhone toggleEdit - disable delete?

开发者 https://www.devze.com 2023-01-21 12:12 出处:网络
When I execute toggleEdit, a red button with a white line in the middle shows up on the left (to enable delete) and a blue button with a white arrow shows up on the right of each cell in my UITable:

When I execute toggleEdit, a red button with a white line in the middle shows up on the left (to enable delete) and a blue button with a white arrow shows up on the right of each cell in my UITable:

 -(IBAction)toggleEdit:(id)sender {
     [self.table setEditing:!self.table.editing animated:YES];
 }

The blue button on the right shows up because for each cell I have:

 cell.editingAccessoryType = UITableViewCellAccessoryDetailDis开发者_JS百科closureButton;

Is it possible when executing toggleEdit to not show the red button on the left?


Yes. In your:

 - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
 }

just return anything other than UITableViewCellEditingStyleDelete for items that are can't be deleted.

0

精彩评论

暂无评论...
验证码 换一张
取 消