我想在我的单元格上添加一个与滑动删除功能相同的自定义按钮。因此,当单击我的自定义按钮时,此按钮将被隐藏,以显示官方的红色“删除”按钮。
所以我做了这样的事情:
/// Controller.m
///
/// @brief Delete icon button pressed. Trigger display of Delete full button
///
- (IBAction)deleteDrug:(id)sender event:(id)event {
NSIndexPath *indexPath = [self indexPathForButton:sender event:event];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[cell setEditing:YES animated:YES];
}
/// CustomCell.m
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
// hide / show "modify" button when entering in edit mode
switch (editing) {
case YES:
self.deleteButton.hidden = YES;
break;
case NO:
self.deleteButton.hidden = NO;
break;
default:
break;
}
}
此时,我的自定义按钮在单击它们时会被隐藏,但没有出现官方的红色“删除”按钮。
有人知道如何处理吗?