views:

224

answers:

1

How can you make a UITextView expand with the text that is inside of it?

+2  A: 

you could try this...

UITextView *textView; // your UITextView
NSString *text; // the text that you want to place in the UITextView
UIFont *textViewFont; // the font that you are using for your UITextView

CGSize size = {255,2000.0f};  //The default width, and max height you want to use

CGSize newSize = [text sizeWithFont:textViewFont
                 constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];

textView.frame = CGRectMake(0,0,newSize.width, newSize.height);
John Stallings