У меня есть свой пользовательский UITableViewCell с UITextView в нем.
После загрузки UITableView мне нужно отрегулировать размер UITableViewCell с размером текста в UITextView.
Поэтому я пытаюсь это так:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
CGFloat resHeigth;
resHeigth = MyCell.textView.contentSize.height;
resHeigth += TOP_BOTTOM_MARGINS * 2;
return resHeigth;
}
Но heightForRowAtIndexPath вызывается перед cellForRowAtIndexPath, где я на самом деле устанавливаю текст.
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;
Итак, возможно ли изменить высоту UITableViewCell?