fix draft scrolling

This commit is contained in:
Michael Kirk 2018-12-07 17:56:50 -05:00
parent 19d76ac95d
commit 52e21be656
1 changed files with 8 additions and 9 deletions

View File

@ -606,7 +606,14 @@ const CGFloat kMaxTextViewHeight = 98;
{
// compute new height assuming width is unchanged
CGSize currentSize = textView.frame.size;
CGFloat newHeight = [self clampedHeightWithTextView:textView fixedWidth:currentSize.width];
CGFloat fixedWidth = currentSize.width;
CGSize contentSize = [textView sizeThatFits:CGSizeMake(fixedWidth, CGFLOAT_MAX)];
// `textView.contentSize` isn't accurate when restoring a multiline draft, so we compute it here.
textView.contentSize = contentSize;
CGFloat newHeight = CGFloatClamp(contentSize.height, kMinTextViewHeight, kMaxTextViewHeight);
if (newHeight != self.textViewHeight) {
self.textViewHeight = newHeight;
@ -616,14 +623,6 @@ const CGFloat kMaxTextViewHeight = 98;
}
}
- (CGFloat)clampedHeightWithTextView:(UITextView *)textView fixedWidth:(CGFloat)fixedWidth
{
CGSize fixedWidthSize = CGSizeMake(fixedWidth, CGFLOAT_MAX);
CGSize contentSize = [textView sizeThatFits:fixedWidthSize];
return CGFloatClamp(contentSize.height, kMinTextViewHeight, kMaxTextViewHeight);
}
#pragma mark QuotedReplyPreviewViewDelegate
- (void)quotedReplyPreviewDidPressCancel:(QuotedReplyPreview *)preview