我知道这两种方法
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return indexPath.section == 0;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
但是我们如何在 UITableView 中禁用删除但启用移动单元格呢?
最佳答案
尝试将以下委托(delegate)方法添加到您的代码中。
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellEditingStyleNone;
}
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
关于ios - 在 UITableView 中禁用删除但启用移动单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21593487/