diff --git a/Framework/Sources/View/UIScrollView+HLSExtensions.m b/Framework/Sources/View/UIScrollView+HLSExtensions.m index 13e792f54..a81e52885 100644 --- a/Framework/Sources/View/UIScrollView+HLSExtensions.m +++ b/Framework/Sources/View/UIScrollView+HLSExtensions.m @@ -242,7 +242,7 @@ - (void)adjustOffsetWithKeyboardEndFrameInWindow:(CGRect)keyboardEndFrameInWindo // Adjust content. Adjust depending on the space available vertically (398 is the horizontal keyboard height on a standard reference iPad) self.contentInset = UIEdgeInsetsMake(self.contentInset.top, self.contentInset.left, - keyboardHeightAdjustment + keyboardDistance * (CGRectGetHeight([UIScreen mainScreen].bounds) - CGRectGetHeight(keyboardEndFrameInWindow)) / (768.f - 398.f), + keyboardHeightAdjustment + keyboardDistance, self.contentInset.right); self.scrollIndicatorInsets = UIEdgeInsetsMake(self.scrollIndicatorInsets.top, self.scrollIndicatorInsets.left, @@ -251,9 +251,16 @@ - (void)adjustOffsetWithKeyboardEndFrameInWindow:(CGRect)keyboardEndFrameInWindo [s_adjustedScrollViews addObject:self]; void (^scrollBlock)(CGRect) = ^(CGRect focusRect) { + CGRect focusRectInScrollView = [self convertRect:focusRect fromView:firstResponderView]; + CGFloat focusViewYPlusHeight = focusRectInScrollView.origin.y + focusRectInScrollView.size.height; + CGFloat keyboardExpandPosition = CGRectGetHeight(self.bounds) - keyboardHeightAdjustment - keyboardDistance; [UIView animateWithDuration:0.25 animations:^{ - CGRect focusRectInScrollView = [self convertRect:focusRect fromView:firstResponderView]; - [self scrollRectToVisible:focusRectInScrollView animated:NO]; + if (focusViewYPlusHeight > keyboardExpandPosition) { + [self setContentOffset:CGPointMake(0.f, focusViewYPlusHeight - keyboardExpandPosition) animated:NO]; + } + else { + [self setContentOffset:CGPointMake(0.f, -(keyboardExpandPosition - focusViewYPlusHeight)) animated:NO]; + } }]; };