mercredi 2 avril 2014

resizing UITextView doesn't obey constraint


Vote count:

0





#define MAXHEIGHT 100

...

- (void)textViewDidChange:(UITextView *)textView
{

CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXHEIGHT)];
CGRect newFrame = textView.frame;
newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
textView.frame = newFrame;
}


I'm trying to resize a UITextView based on the text input. I want to constrain the height of the textview to 100. Everything about this solution works except that it doesn't constrain the height to 100 (i.e. it will continuing expanding in height when the user continually adds text?



asked 38 secs ago

A user

1,268





Aucun commentaire:

Enregistrer un commentaire