当我使用滑动手势触发 DeleteConfirmationButton 出现然后触摸它时,我有一个自定义 TableViewCell(没有 Interface Builder)按钮像往常一样消失。
但是当我使用默认编辑按钮将整个 TableView 设置为编辑模式时:
[self.navigationItem setRightBarButtonItem:[self editButtonItem]];
然后触摸 DeleteConfirmationButton 它只会变成深红色并且不会消失。
有什么想法吗?
PS:是否可以在使用滑动手势时不显示按钮(因此它仅在编辑模式下可用)?
编辑:理解我的意思(我只使用删除按钮清除星星)
最佳答案
要删除删除按钮,您可以尝试:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// delete stars
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
您的 PS 的答案是肯定的。您可以使用以下内容:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (!tableView.editing) {
return UITableViewCellEditingStyleNone;
}
return UITableViewCellEditingStyleDelete;
}
关于ios - 使用自定义 UITableViewCell 时,删除确认按钮不会消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4238177/