How do I size a UITextView to its content? from stack overflow!

see:http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content

 

 

code:

 

CGRect frame = _textView.frame;
frame.size.height = _textView.contentSize.height;

_textView.frame = frame; 

 

note this line:

 

One thing to note is that the correct contentSize is only available after the UITextView has been added to the view with addSubview. Prior to that it is equal to frame.size

 

 

posted @ 2012-07-17 23:59  snowlueng  阅读(142)  评论(0编辑  收藏  举报