UITableViewCell があり、編集が有効になるように構成しました。すべて正常に動作しますが、私の問題は、丸い削除ボタン (「|」の付いた円) を 2 回目に押したときに、削除の確認が消えないことです。
なぜこれが起こるのか誰か知っていますか?
[編集]
毎秒呼び出されるメソッドに絞り込み、そのメソッドで、編集可能な UITableView で beginUpdates と endUpdates を呼び出します。誰かが回避策を知っていますか?
UITableViewCell があり、編集が有効になるように構成しました。すべて正常に動作しますが、私の問題は、丸い削除ボタン (「|」の付いた円) を 2 回目に押したときに、削除の確認が消えないことです。
なぜこれが起こるのか誰か知っていますか?
[編集]
毎秒呼び出されるメソッドに絞り込み、そのメソッドで、編集可能な UITableView で beginUpdates と endUpdates を呼び出します。誰かが回避策を知っていますか?
次のようなものを追加してみてください。
- (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];
}
行を再ロードすることが重要です。
tableView が編集モードの場合は beginUpdates と endUpdates メソッドの使用を避けることで解決しました。代わりに、編集モードが YES の場合はセルを手動で更新します。
暗闇の中で突き刺さなければならなかった場合...おそらくediting
trueに設定してから、falseに戻していません。の値を設定するために呼び出すメソッドは、呼び出さediting
れるたびにその値を逆にするようにしてください。
- (void)setTableDelete
{
bool temp = !myTableView.editing;
[myTableView setEditing:temp animated:YES];
}