Have you tried this? I added a button with the current code in my action method, I see that the height changes to the height of the text.
CGSize size = [self.textView systemLayoutSizeFittingSize:self.textView.contentSize]; CGRect frame = self.textView.frame; frame.size.height = size.height; self.textView.frame = frame;
Edit
I added a lower space to restrict the supervisor and set it as an IBOutlet property, then in viewDidAppear I changed the restriction constant.
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.textView.contentInset = UIEdgeInsetsZero; CGSize size = [self.textView systemLayoutSizeFittingSize:self.textView.contentSize]; self.heightConstraint.constant -= size.height - self.textView.frame.size.height; self.textView.scrollEnabled = NO; [self.textView setNeedsUpdateConstraints]; }
gabbler Nov 05 '14 at 4:42
source share