選択されていないときに UITableViewCell が contentView をアニメーション化しない理由を理解するのに苦労しています。
セルを展開および折りたたむコードをいくつか作成しましたが、セルを折りたたむと、高さはアニメーション化されますが、contentView はアニメーション化されません。実際には contentView が削除されているようです。
記録のために、UILabel を contentView に追加しました。展開すると、それに応じて UILabel のフレームのサイズが変更されますが、折りたたむと、UILabel はアニメーションなしで閉じられるか非表示になります。
何かアドバイス?
サンプルコードは次のとおりです。
/* Expanding and collapsing code */
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self cellIsSelected:indexPath])
{
//Item is clicked, unclick it
[self.selectedIndexes removeObject:indexPath];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
else
{
//Item is not clicked. Deselect others and select this
[self.selectedIndexes removeAllObjects];
[self.selectedIndexes addObject:indexPath];
}
[tableView beginUpdates];
[tableView endUpdates];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self cellIsSelected:indexPath]) {
return 150;
}
return [tableView rowHeight];
}