I have my custom UITableViewCell with UITextView in it. After UITableView loads I need to adjust the size of the UITableViewCell with size of the text in a UITextView. So I am trying to it like this:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
CGFloat resHeigth;
resHeigth = MyCell.textView.contentSize.height;
resHeigth += TOP_BOTTOM_MARGINS * 2;
return resHeigth;
}
But heightForRowAtIndexPath called before cellForRowAtIndexPath, where I actually set the text.
MyViewCell *cell = (MyViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"MyCellView" owner:self options:nil];
cell = MyCell;
}
cell.textView.text = @"Text for test\nTest";
CGRect frame = cell.textView.frame;
frame.size.height = cell.textView.contentSize.height;
cell.textView.frame = frame;
So, Is it possible to change the height of the UITableViewCell?