I want to resize a UITextView when the keyboard appears, but I cannot do this. I created a single view with a UITextView in it. In the code, I would like to manually resize this text view. I'm doing it:
_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 field between the text view and the superview can be greater than or equal to 0.
When I run the application, it gives an error that the restrictions cannot be satisfied at the same time:
"<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 am not sure how to make sure that all restrictions are met. Can anyone give me a hand on this?
Thanks!
source share