I have a uitextview, I would like to dynamically load it based on the contents, the answer from this link doesnt work on iOS11. https://stackoverflow.com/a/20999067/365384
CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
CGRect newFrame = textView.frame;
newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
textView.frame = newFrame;
The only way I can do is use constraint update constraint
CGFloat fixedWidth = self.textView .frame.size.width;
CGSize newSize = [self.textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
self.textViewHeightConstraint.constant = newSize.height;
I am working on a universal app, and I dont want use too many constraints in the code. Is there any way to fix it without adding extra constraint?