-1

UITableViewCell があり、編集が有効になるように構成しました。すべて正常に動作しますが、私の問題は、丸い削除ボタン (「|」の付いた円) を 2 回目に押したときに、削除の確認が消えないことです。

なぜこれが起こるのか誰か知っていますか?

[編集]

毎秒呼び出されるメソッドに絞り込み、そのメソッドで、編集可能な UITableView で beginUpdates と endUpdates を呼び出します。誰かが回避策を知っていますか?

4

3 に答える 3

0

次のようなものを追加してみてください。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    Dashboard *dashboard = [dashboards dashboardAtIndex:indexPath.row];
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        NSLog(@"delete");
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        NSLog(@"insert");
    }

    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
}

行を再ロードすることが重要です。

于 2012-08-13T13:39:05.950 に答える
0

tableView が編集モードの場合は beginUpdates と endUpdates メソッドの使用を避けることで解決しました。代わりに、編集モードが YES の場合はセルを手動で更新します。

于 2012-08-15T10:52:15.200 に答える
0

暗闇の中で突き刺さなければならなかった場合...おそらくeditingtrueに設定してから、falseに戻していません。の値を設定するために呼び出すメソッドは、呼び出さeditingれるたびにその値を逆にするようにしてください。

- (void)setTableDelete 
{
    bool temp = !myTableView.editing;
    [myTableView setEditing:temp animated:YES];

}
于 2012-08-13T13:34:10.847 に答える