如何禁用特定单元格ios中的编辑模式?

sab*_*eer 5 uitableview ios ios6

我在可编辑模式下创建tableview所有tableview行都包含( - )符号,但我需要一些单元格不在可编辑模式下,如果有可能,谢谢

Dee*_*ola 20

根据UITableViewDataSource的Apple文档, https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewDataSource_Protocol/Reference/Reference.html

您可以使用 tableView:canEditRowAtIndexPath:


Dan*_*izl 8

是的阅读文档将揭示这个问题.有助于您的问题是:tableView:canEditRowAtIndexPath:

这应该让你朝着正确的方向前进.

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

    BOOL edit = NO;

    if(indexPath.row == 2) {

        edit = YES;
    }

    return edit;
}
Run Code Online (Sandbox Code Playgroud)