У меня есть UITableview
с несколькими многократными таблицами TableViewCells.
В одной ячейке у меня есть UITextView
, который меняет размер, чтобы соответствовать его содержимому. Теперь мне просто нужно изменить размер contentView
TableViewCell, чтобы я мог читать текст while. Я уже пробовал:
cell2.contentView.bounds.size.height = cell2.discriptionTextView.bounds.size.height;
Или:
cell2.contentView.frame = CGRectMake(0, cell2.discriptionTextView.bounds.origin.y,
cell2.discriptionTextView.bounds.size.width,
cell2.discriptionTextView.bounds.size.height);
В методе:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath {}
Но это не сработает.
Кто-нибудь знает, как это сделать?
Новый код:
@implementation AppDetail
CGFloat height;
…
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{…
cell2.TextView.text = self.text;
[cell2.TextView sizeToFit];
height = CGRectGetHeight(cell2.TextView.bounds);
…
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 143;
}
if (indexPath.row == 1) {
return height;
}
return 0;
}