From c5aa13c08ab3e491f73a4ed32522ced83a53aebd Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Wed, 23 May 2018 10:22:14 -0700 Subject: [PATCH 1/2] Adjust keyboard avoiding behavior Stop adjusting `scrollView.contentOffset` and let the system natively scroll because of the `scrollView.contentInset` change --- ...UIViewController+Stripe_KeyboardAvoiding.m | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Stripe/UIViewController+Stripe_KeyboardAvoiding.m b/Stripe/UIViewController+Stripe_KeyboardAvoiding.m index 83797df7563..1150e3519b3 100644 --- a/Stripe/UIViewController+Stripe_KeyboardAvoiding.m +++ b/Stripe/UIViewController+Stripe_KeyboardAvoiding.m @@ -78,10 +78,8 @@ - (void)doKeyboardChangeAnimationWithNewFrame:(CGRect)keyboardFrame { self.lastKeyboardFrame = keyboardFrame; if (self.managedScrollView) { - UIScrollView *scrollView = self.managedScrollView; UIView *scrollViewSuperView = self.managedScrollView.superview; - UIView *lastResponder = self.lastResponder; UIEdgeInsets contentInsets = scrollView.contentInset; UIEdgeInsets scrollIndicatorInsets = scrollView.scrollIndicatorInsets; @@ -96,28 +94,11 @@ - (void)doKeyboardChangeAnimationWithNewFrame:(CGRect)keyboardFrame { self.currentBottomInsetChange += bottomInsetDelta; scrollView.contentInset = contentInsets; scrollView.scrollIndicatorInsets = scrollIndicatorInsets; - - if (!lastResponder || bottomIntersection.size.height <= 0) { - scrollView.contentOffset = CGPointMake(0, -scrollView.contentInset.top); - } - else { - // the keyboard is visible - CGRect responderFrame = [lastResponder convertRect:lastResponder.bounds toView:scrollView]; - CGRect keyboardFrameInScrollViewCoords = [scrollView convertRect:keyboardFrame fromView:nil]; - CGPoint offset = scrollView.contentOffset; - - CGFloat topOfScreenOffset = CGRectGetMinY(responderFrame); - CGFloat topOfKeyboardOffset = CGRectGetMinY(responderFrame) - CGRectGetMinY(keyboardFrameInScrollViewCoords); - offset.y = ((topOfScreenOffset + topOfKeyboardOffset) / 2) - scrollView.contentInset.top; - offset.y = MAX(offset.y, -scrollView.contentInset.top); - scrollView.contentOffset = offset; - } } if (self.keyboardFrameBlock) { self.keyboardFrameBlock(keyboardFrame, self.lastResponder); } - } @end From 6e3a9438188915a9edffcdb86fb1a3e424543c28 Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Thu, 24 May 2018 11:15:00 -0700 Subject: [PATCH 2/2] Add CHANGELOG entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cb720fbc56..df803517e86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Adjusts scroll view content offset behavior when focusing on a text field [#943](https://github.com/stripe/stripe-ios/pull/943) + ## 13.0.1 2018-05-17 * Fixes an issue in `STPRedirectContext` causing some redirecting sources to fail in livemode due to prematurely dismissing the `SFSafariViewController` during the initial redirects. [#937](https://github.com/stripe/stripe-ios/pull/937)