UITableView に動的に作成されたセクションを設定するプロジェクトがあります。すべてがうまく機能し、期待どおりに各セクション内でオブジェクトを追加および削除できます。
スクリプトは現在、そのセクションのすべてのメンバーも削除されたときに、TableView からセクションを削除するように設定されています。これも問題なく動作しますが、リストの最後のセルを削除しようとすると、最後のセクションを削除すると奇妙なアニメーションのバグが発生します。セクション/セルの削除アニメーションは期待どおりに再生されますが、区切り線がセクション ヘッダーの高さまで跳ね上がり、見栄えが悪くなります。スクリーン キャプチャが機能しないので、携帯電話でキャプチャしたビデオを投稿します。画質についてはあらかじめお詫びします。ビデオでは、最初の 2 つの削除が正常に機能し、次に 3 つ目と最後のアニメーションの問題が示されています。
http://www.youtube.com/watch?v=eE0j5tCSRIQ
削除を処理するコードは次のとおりです。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
//Set active floor key
NSObject *key = [[[[self patientList] allKeys]sortedArrayUsingSelector:@selector(compare:)]objectAtIndex: indexPath.section];
[[self tableView]beginUpdates];
//Delete
[[self managedObjectContext]deleteObject:[self getPatientFromIndexPath: indexPath]];
[[[self patientList]objectForKey: key]removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
//Save
[[self managedObjectContext]save: nil];
//Delete section if no patients left
if ([[[self patientList]objectForKey: key]count] == 0) {
[[self patientList]removeObjectForKey:key];
[tableView deleteSections:[NSIndexSet indexSetWithIndex: indexPath.section] withRowAnimation:(UITableViewRowAnimationFade)];
}
[[self tableView]endUpdates];
}
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
}
}
これについては何も見つかりませんでした。私は iOS プログラミングが初めてなので、途方に暮れています。