显示UITableViewCell重新排序控制而不将单元格内容向右移动?

Gut*_*ujo 7 iphone objective-c uitableview

我实现了moveRowAtIndexPath来重新排列UITableView中单元格的顺序并设置UITableViewCellEditingStyleNone,这样它在编辑模式下只显示重新排序的控件.

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

    return UITableViewCellEditingStyleNone;

}
Run Code Online (Sandbox Code Playgroud)

它工作正常但是当进入编辑模式时,它仍然向右缩进每个单元格的内容,期望为删除或插入控件腾出空间.我没有使用它,所以它变成一个奇怪的空白空间.有没有办法在编辑模式下避免这种行为?

Sha*_*aun 4

您是否尝试过在 UITableViewCell 上将 shouldIndentWhileEditing 设置为 NO ?

  • 非常感谢。根据您的回答,我找到了 UITableViewDelegate 方法 tableView:shouldIndentWhileEditingRowAtIndexPath: ,它为所有单元格设置选项。 (2认同)