4

ユーザーが UITableViewCell を削除することを決定したときに表示される 2 番目の確認ダイアログがあります。通常の状態のテーブルビューは次のとおりです。

普通


そして、テーブル全体が編集モードになったときは次のようになります。

通常の編集モード


ユーザーが左側の赤いマイナス記号の 1 つをタップすると、セルは削除確認モードになります。

削除確認モード


ユーザーが表示されたばかりの削除ボタンをタップすると、次のアクション シートが表示されます。

二次確認


ここで問題が発生します。ユーザーがマップを削除することを確認した場合、すべて問題ありません。ただし、キャンセル ボタンを押すと、アクション シートは消えますが、テーブル ビューは次のようになります。

削除確認ボタンは選択された状態ではなくなり、ビューから非表示になっているはずです

問題は、削除確認ボタンが選択された状態ではなくなり、ビューから非表示になっていることです。ご覧のとおり、そうではありません。ドキュメントの検索は結果なしで終了しました。setEditing:NOテーブルを通常の編集状態のままにしたいので、したくありません。何か案は?

編集1:これが内部で起こっていることですtableView:commitEditingStyle:forRowAtIndexPath:

- (void)tableView:(UITableView*)tableView commitEditingStyle:
    (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath {
    NSInteger finalIndex = [self getFinalIndexForIndexPath:indexPath];

    NSString* mapTitle = ((PreviewDataObject*)[[[SingletonDataController sharedSingleton]
        getImportedOrSavedMapPreviews:masterIdentifierString] 
        objectAtIndex:finalIndex]).titleString;

    UIActionSheetWithIndexPath* sheet = [[UIActionSheetWithIndexPath alloc] initWithTitle:
        [NSString stringWithFormat:@"Are you sure you want to delete the map '%@'?", 
        mapTitle] delegate:self cancelButtonTitle:@"Cancel" 
        destructiveButtonTitle:@"Delete Map" otherButtonTitles:nil];
    sheet.indexPath = indexPath;
    [sheet showFromTabBar:[AppDelegate appDelegate].tabBarController.tabBar];
    [sheet release];
}
4

4 に答える 4

1

その後、本当に、本当に、本当に削除したいかどうかを尋ねる AlertView を提示することもできます。

ボタンをオンにしてから [削除] を押すという 2 段階のプロセスは、十分な確認となるはずです。

あなたがしていることをすることは、私には標準的な慣行ではないように思えます。その領域に入ると、フレームワークに穴が見つかります。

于 2012-06-05T14:25:40.373 に答える
1

削除を3回押す必要があるのは悪い考えだという上記の議論に同意します。

ただし、他のアクションでは、行をリセットする正当な理由がある場合があります。最も簡単な解決策は、その 1 行をリロードすることです。

スウィフト 2.2:

tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
于 2016-06-09T19:49:25.613 に答える
0

編集モードを終了するだけです (Swift):

tableView.setEditing(false, animated: true)
于 2016-10-27T09:34:15.980 に答える
0

これを試して、あなたのために働いているかどうか教えてください.

  -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  {
      if (editingStyle == UITableViewCellEditingStyleDelete)
       {
           // Delete the row from the data source.

           [arr removeObjectAtIndex:indexPath.row];


           [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
         }
        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.
        }   
    }
于 2012-05-07T11:50:16.440 に答える