UITableViewCell:允许选择性删除 [英] UITableViewCell: Allowing Selective Deletion

查看:58
本文介绍了UITableViewCell:允许选择性删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格视图,并希望允许对所有单元格进行重新排序,但是有些单元格我不希望被删除。当UiTableView进入删除模式时,我不希望红色的-按钮出现在左侧,也不想通过滑动手势调出这些单元格的删除按钮,但希望其他用户也可以使用。有任何想法吗?

I have a table view and want to allow reordering of all cells, however there are certain cells that I do not want to be allowed to be deleted. when the UiTableView is put into deletion mode I do not want the red '-' button to appear on the left hand side, and do not want the swipe gesture to bring up the Delete button of these cells but want it to happen for the others. Any ideas?

推荐答案

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

    //if we cant delete the object represented at the index path
    if ([[tableViewObjectsArray objectAtIndex:indexPath.row] canBeDeleted] == NO){
        return UITableViewCellEditingStyleNone;
    }
    //otherwise allow the deletion
    else{
        return UITableViewCellEditingStyleDelete;
    }
}

当然,这会留一个空白, '按钮应该是,但不允许删除。并且也不允许刷卡删除。

Of course this leaves an empty space where the '-' button should be, but it does not allow deletion. And also does not allow the swipe deletion either.

这篇关于UITableViewCell:允许选择性删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆