我想在我的单元格上添加一个自定义按钮,与滑动删除功能做同样的事情。所以当点击我的自定义按钮时,这个会隐藏起来让官方出现红色的“删除”按钮。以编程方式触发UITableViewCell“删除”按钮
所以我做了这样的事情:
/// 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;
}
}
在这一刻,当你点击它们,但官方的红色“删除”按钮并未显示在我的自定义按钮越来越隐藏。
做一个人知道如何处理这个?
'[tableView setEditing:YES animated:YES];'会在单元格左边放置一个红色图标(允许您调出右边的红色“删除”按钮)。我不想要它。我真的希望我的自定义按钮直接显示右边的红色“删除”按钮。 – Yaman 2013-03-18 15:57:13
我想这是真的。它可能是因为你试图覆盖预期的行为,你可能需要去全距离并处理删除按钮。 – 2013-03-18 15:58:11
叶我害怕这将是唯一的方式... Thx为你的帮助瑞安。 – Yaman 2013-03-18 16:00:59