ios開發問題,經驗證,textview的contentsize.height不能準確判斷高度

IOS7環境中,設置UITextView.text並不能當即更新contentSize,再用textView.contentSize.height沒法獲取當前內容的高度。採用如下方法能夠解決這個問題。spa

1
2
3
4
5
6
7
8
9
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;
     }
相關文章
相關標籤/搜索