为了不允许多行选择您应该使用tableView:shouldIndentWhileEditingRowAtIndexPath:
混合cell.selectionStyle = UITableViewCellSelectionStyleNone
。
这里是从我的代码示例:
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath*)indexPath {
if (indexPath.row < 4) {
return YES;
} else {
return NO;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// (...) configure cell
if (indexPath.row < 4) {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
}
是我没有,但这种方法是没有得到调用。 – Herman 2012-07-09 20:07:32
编辑期间启用多项选择时,不会调用editingStyleForRowAtIndexPath。 – shim 2015-08-25 21:09:03