7

UITableView 内のセルの順序を並べ替えるために moveRowAtIndexPath を実装し、UITableViewCellEditingStyleNone を設定して、編集モードのときに並べ替えコントロールのみを表示するようにしました。

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

    return UITableViewCellEditingStyleNone;

}

正常に動作しますが、編集モードに入ると、削除または挿入コントロールのためのスペースを確保するために、各セルの内容が右にインデントされます。どちらも使っていないので変な空きスペースになります。編集モードでこの動作を回避する方法はありますか?

4

2 に答える 2

4

UITableViewCellでshouldIndentWhileEditingをNOに設定してみましたか?

于 2012-12-13T01:34:56.837 に答える
4

この UITableViewDelegate メソッドを試してください。左に [削除] ボタンを表示せず、行を右にシフトせずに並べ替えが可能になります。

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewCellEditingStyleNone; 
}

- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;
}

- (BOOL)tableView:(UITableView *)tableview canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
于 2015-01-26T07:07:37.713 に答える