【问题标题】:allow editing in uitableview, but not in one row允许在uitableview中编辑,但不能在一行中
【发布时间】:2011-06-30 12:42:19
【问题描述】:

我有一个包含多个部分的 UITableView。当我将表格设置为编辑模式时,我希望一个部分(仅包括 1 行)不显示编辑符号并且不调用 tableView:commitEditingStyle:forRowAtIndexPath:。
这可能吗?
问候 约翰

【问题讨论】:

    标签: ios uitableview


    【解决方案1】:

    这里我假设第 1 节和第 0 行无法编辑

    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
        // Return NO if you do not want the specified item to be editable.
    
        if (indexPath.section == 1) {
            if (indexPath.row == 0) {
                return NO;  
            }
        }
    
        return YES;
    }
    

    【讨论】:

    • 非常感谢。这正是我所需要的。约翰
    猜你喜欢
    • 1970-01-01
    • 2021-07-29
    • 2014-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-16
    • 2017-08-23
    • 1970-01-01
    相关资源
    最近更新 更多