【发布时间】:2016-04-17 14:29:53
【问题描述】:
在UITableViewCell 中设置UITextview 时遇到问题。由于函数 heightforrowatindexpath 在 cellforrowatindexpath 之前运行,所以我无法计算 UITextview 的内容大小。
我只是通过cellforrowatindexpath 函数中的textview.contentSize.height 来计算大小。
我基本上希望UITextview contentHeight 适合UITableViewCell,因此每个UITextView 都看不到滚动,它会通过增加UITableViewCell 的高度来显示全部内容。
我也是一个UILabel,就在UITableViewCell中的UITextView之上,我试图为两者设置约束,但无法实现我的目标。
如何在以下函数中动态计算UITableViewCell 的大小:
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
}
P.S: 是否可以根据设备高度使用自动布局或其他技术稍微增加UITableViewCell 的高度。
【问题讨论】:
标签: ios swift uitableview autolayout uitextview