From 5dda287705998d2c772eac0607ddb97168d19e2b Mon Sep 17 00:00:00 2001 From: Bob Spryn Date: Sun, 13 Apr 2014 22:51:31 -0600 Subject: [PATCH] Removed the frame setting in 'updateText'. I really don't think a view should be randomly updating it's own frame like that unexpectedly. Definitely not in an autolayout world. Also changed t 'suggestedFrameSizeToFitEntireStringConstraintedToWidth' to just use the proper method on '_textView' 'sizeThatFits'. Believe that's the most appropriate way to get an accurate height, though it's probably using similar code to what was already there internally --- STTweetLabel/STTweetLabel.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/STTweetLabel/STTweetLabel.m b/STTweetLabel/STTweetLabel.m index dbd796a..bcd517d 100644 --- a/STTweetLabel/STTweetLabel.m +++ b/STTweetLabel/STTweetLabel.m @@ -225,8 +225,6 @@ - (void)updateText _textView.textContainer.lineFragmentPadding = 0; _textView.textContainerInset = UIEdgeInsetsZero; _textView.userInteractionEnabled = NO; - [_textView sizeToFit]; - self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, _textView.frame.size.height); [self addSubview:_textView]; } @@ -237,7 +235,7 @@ - (CGSize)suggestedFrameSizeToFitEntireStringConstraintedToWidth:(CGFloat)width if (_cleanText == nil) return CGSizeZero; - return [_textStorage.attributedString boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size; + return [_textView sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)]; } #pragma mark -