Resize a UITextView vertically with text using the AutoLayout function

I was hoping to use the answer here to solve my problem, but the UITextView has no intrinsicContentSize method. Does anyone know how I can do this? On Android, all I have to do is say β€œwrap-content” in the layout file. But here on iOS, hell.

As for suggestions, resize the UITextField when typing (using Autolayout) , I'm not sure why these guys use IBAction in the delegate signature. In any case, they do not work for me.

UPDATE

I thought I solved the problem with the following. But "growth" is temporary. The field is only growing as I type. As soon as I stop typing, it returns to a smaller size. How can I make it more permanent?

 - (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { [self resizeTextViewToFitContent:textView]; } - (void)resizeTextViewToFitContent:(UITextView *)textView { CGRect frame = textView.frame; frame.size.height=[self heightOfTextView:textView]+5; textView.frame=frame; } -(CGFloat)heightOfTextView:(UITextView *)textView { CGRect reviewTextFrame = [textView.attributedText boundingRectWithSize:CGSizeMake(textView.bounds.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil]; return CGRectGetHeight(reviewTextFrame); } 
0
ios iphone autolayout uitextview
Jan 24 '15 at 20:16
source share

No one has answered this question yet.

See similar questions:

51
Resize UITextField during input (using Autolayout)
9
Resize UITextField horizontally with text using auto-layout
0
iOS: UITextView dial height equal to content height

or similar:

2123
Align text vertically at top in UILabel
705
Placeholder in UITextView
618
Cocoa Auto Detect: Content Crawl and Content Compression Matching
506
How to configure a UITextView to its contents?
463
How to lose margin / padding in UITextView?
361
How to remove keyboard for UITextView with return key?
324
Emulating compliance behavior using AutoLayout restrictions in Xcode 6
150
UITextView that expands to text using auto layout
61
Center text vertically in a UITextView
0
UIScrollView contentOffset jumps after animation - in version 3.0 beta 5