0
我有一個可編輯的textview內的tableviewcell,如蘋果聯繫人的字段備註,但tableviewcell不會調整與textview的大小。我認爲問題在於這種方法。有誰能夠幫助我?uitableviewview與uitextview
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0 && indexPath.row == 0)
{
if (self.textView.contentSize.height >= 44)
{
float height = [self heightForTextView:self.textView containingString:self.model];
return height + 8; // a little extra padding is needed
}
else
{
return self.tableView.rowHeight;
}
}
else
{
return self.tableView.rowHeight;
}
}
你的textview有靜態高度還是動態的?你是否試圖將高度存儲在高度變量中? –
你需要重新加載行。 [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationFade]; 這將再次重新創建您的文本字段。所以保持你的文字。 –