Tcacenco Daniel
Tcacenco Daniel

Reputation: 445

Auto resize UITextView in UIScrollView

I have a question, how can I resize a textview in a scrollview and scrollview also must resize to be conformable with what size the textview will be. Thank you.

Upvotes: 2

Views: 544

Answers (1)

MSU_Bulldog
MSU_Bulldog

Reputation: 3519

Without auto layout it is much easier. Just get the contentSize property of the UITextView:

float textViewHeight = textView.contentSize.height;

And then set scroll view content size according to the content size of the text view:

scrollview.contentSize = CGSizeMake(320,textViewHeight + 100);

This will make the height of the scroll view the height of the content size of the textview plus 100 pixels (in case you have other stuff in your scroll view).

Upvotes: 1

Related Questions