IOS7环境UITextView文字高度的计算

IOS7环境中,设置UITextView.text并不能立即更新contentSize,再用textView.contentSize.height无法获取当前内容的高度。采用以下方法可以解决这个问题。

 

 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;
    }

 

 

 

posted @ 2014-05-07 09:18  andy_shen  阅读(172)  评论(0编辑  收藏  举报