0

Appleが提供する編集機能を使用せずに、配列内の行を削除しようとしています(の行に沿ったもの-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath)。したがって、ユーザーがいくつかの行を選択し、テーブル ビューにないボタンを押すと、それらの行がフェードアウトします。Apple は、ここである種のものを提供しています。

私が使用しているコードは、削除する行の配列を呼び出します。これは他の場所で定義されており、それらの特定の行で配列人口オブジェクトを削除し、フェード スタッフを使用してすべての行を削除することになっています。

- (void) deleteTableRow {

NSIndexPath *current;
NSLog(@"to be deleted: %@", toBeDeleted); //toBeDeleted is the array with the NSIndexPath items

for(int i=0; i < [toBeDeleted count]; i++) {
    current = [toBeDeleted objectAtIndex: i];

    [tableData removeObjectAtIndex:current.row]; //Remove the necessary array stuff

}
tv = [UITableView alloc];
[tv beginUpdates];
[tv deleteRowsAtIndexPaths:toBeDeleted withRowAnimation:UITableViewRowAnimationFade];
[tv endUpdates];
    // Do whatever data deletion you need to do...

}

tvはヘッダー ファイルで定義されており、UITableView の参照アウトレットです。

だからここに私の主な質問があります:

  • 私の UITableView は UITableViewController ではないため (代わりにビューの一部です)、これは可能ですか?
  • 可能であれば、なぜこれが機能しないのですか?
4

0 に答える 0