我正在使用一个 UITextView
,通过点击“更多”按钮可以扩展它。但是问题是:
在 iOS6 中,我使用了以下代码:
self.DescriptionTextView.text = @"loong string";
if(self.DescriptionTextView.contentSize.height>self.DescriptionTextView.frame.size.height) {
//set up the more button
}
问题在于在iOS7上,contentSize.height
返回的值(要小得多)与它在iOS6上返回的值不同。
为什么会这样?如何解决?
iOS7上contentSize.height
返回值比iOS6上小是因为UITableView计算高度的方式已更改。解决方法是使用-systemLayoutSizeFittingSize:
来获取正确的高度。