I want to change the height limit of a UITextView programmatically, so I set the limit as an output to my controller as follows:
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *descriptionHeightConstraint;
To change it, I do the following:
self.descriptionHeightConstraint.constant = self.description.contentSize.height;
This works if I do it in viewDidAppear , but the problem is that I see how the height changes after the view is displayed, which is not very convenient for the user, so I tried to do this in viewWillAppear , but did not work there, the height does not change . Calling setNeedsUpdateConstraints after changing the constraint did not work either.
Why does it work in viewDidAppear and not in viewWillAppear? Any workaround?
Thanks in advance!
ios height autolayout constraints
mxch Jan 05 '14 at 4:18 2014-01-05 04:18
source share