私の UITableView には 1 つのセクションがあり、すべてのセルが表示されている場合は合計 6 になります。
表示および非表示にしたいセルは 1 つだけです。
概要は次のとおりです。
セル 0 - 常に表示
セル 1 - 常に表示
セル 2 - 常に表示
セル 3 - 常に表示
セル 4 - 最初は非表示 / セル 3 をタップすると表示または非表示になります
セル 5 - 常に表示
これは、didSelectRowAtIndexPath を使用してセルをアニメーション化/表示するために試したサンプルです。私が正しい軌道に乗っているかどうかはわかりませんが、誰かが見て、私がどこを台無しにしたかを理解するのを手伝ってくれたら、とても感謝しています!
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 3)
{
if (self.indexPathSelected != indexPath)
{
[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:self.indexPathSelected.row+1 inSection:self.indexPathSelected.section]].hidden = YES;
[tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop];
[tableView beginUpdates];
[[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section]] performSelector:@selector(setHidden:) withObject:NO afterDelay:0.25];
self.indexPathSelected = indexPath;
[tableView endUpdates];
return;
}
}
}
したがって、セル 3 をタップすると、最後のセルがちらつくだけです。