IOS7环境中,设置UITextView.text并不能当即更新contentSize,再用textView.contentSize.height没法获取当前内容的高度。采用如下方法能够解决这个问题。
spa
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { CGRect textFrame=[[self.textView layoutManager]usedRectForTextContainer:[self.textView textContainer]]; height = textFrame.size.height; }else { height = self.textView.contentSize.height; }