I have a UITableView
that has a number of static cells. There are no prototypes.
One cell as a UITextField
and a UITextView
. I want the UITextView
to be hidden depending on the input of the UITextField
. This is not a problem.
My problem is that I would like to resize the UITableViewCell
that both of these controls are in - so that when the UITextView
is hidden the cell height is 30, and when it is displayed its height is 70 (this makes the UITextView
fully visible).
As they are static cells, I have simply set the height in IB to 70 (the largest) so when the UITextView
is hidden there is a lot of unused space in the cell which I would like to get rid of by changing the cell height to 30.
I assume that I would need to tell the cell to redraw using something like
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:@[indexPathOfYourCell] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
But how do I get the reference to the cell from a subview (the UITextField
)?
Also how would I tell the cell the new height? Should I tag it and use
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
as I would for dynamic prototype sizing?