2017-04-25 18 views
0

テーブル編集モードを使用しているときに、表のセルの内容が左側にシフトしないようにします。で提案されているようにUITableViewのshouldIndentWhileEditingRowAtIndexPath:が呼び出されていません

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

:私は私のビューコントローラで、次のUITableViewDelegateメソッドを実装し

Prevent indentation of UITableViewCell (contentView) while editing

しかし、今までと呼ばれていないようです。これはどちらか動作しませんでした:私は、テーブルビューのdelegate性質があることをダブルチェック

- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView 
        editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSMutableArray<UITableViewRowAction *> *actions = [NSMutableArray array]; 
    id clearHandler = ^(UITableViewRowAction *action, NSIndexPath *indexPath) { 
      ... 
    }; 
    UITableViewRowAction *clearAction = [UITableViewRowAction 
             rowActionWithStyle:UITableViewRowActionStyleDestructive 
             title:@"Clear\nStatus" 
             handler:clearHandler]; 
    [actions addObject:clearAction]; 

    id editHandler = ^(UITableViewRowAction *action, NSIndexPath *indexPath) { 
     ... 
    }; 
    UITableViewRowAction *editAction = [UITableViewRowAction 
             rowActionWithStyle:UITableViewRowActionStyleNormal 
             title:@"Edit" 
             handler:editHandler]; 
    [actions addObject:editAction]; 

    return actions; 
} 

:私はこのように定義されたカスタムエディット行アクションのカップルを使用してい

cell.shouldIndentWhileEditing = NO; 

をビューコントローラをポイントします。ほかに何が足りないのですか?

テーブルビュースタイルはグループ化されていません。つまり、プレーンです。

+0

グループ化されたテーブルビューを使用していますか? 'UITableView.h':"このメソッドはグループ化されたスタイルテーブルビューにのみ適用されます。 " – norders

+0

あなたはあなたの問題を解決したかしなかったのですか? –

+0

@nordersテーブルスタイルは平易です。だから、プレーンなテーブルビューではこれを達成することはできませんか? – iosdude

答えて

0

セットデリゲートとデータソースの方法

その後、

  • あなたはtrueにのUITableViewのallowsSelectionDuringEditingプロパティを設定します。
関連する問題