I would like to resize a UITextView when the keyboard shows up but I can't seem to do this. I've created a single view with an UITextView in it. In code, I would like to manually resize the height of this text view. I do this:
_textView.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:_textView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:216.0f];
[_textView addConstraint:constraint];
In Interface Builder, I say that the margin between the text view and the superview can be greater than or equal to 0.
When I run the app, it gives the error that constrains can't be satisfied simultanously:
"<NSLayoutConstraint:0x886e550 V:[UITextView:0x7b0fa00(216)]>",
"<NSLayoutConstraint:0x886f7c0 UITextView:0x7b0fa00.bottom == UIView:0x886e3c0.bottom>",
"<NSLayoutConstraint:0x886f700 V:|-(0)-[UITextView:0x7b0fa00] (Names: '|':UIView:0x886e3c0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x71a2d10 h=--- v=--- V:[UIWindow:0x8a792f0(480)]>",
"<NSAutoresizingMaskLayoutConstraint:0x71a1490 h=-&- v=-&- UIView:0x886e3c0.height == UIWindow:0x8a792f0.height - 20>"
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x886e550 V:[UITextView:0x7b0fa00(216)]>
I'm not sure on how to make sure that all constraints are satisfied. Could anyone give me a hand in this?
Thanks!