Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust keyboard avoiding behavior #943

Merged
merged 2 commits into from
May 24, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions Stripe/UIViewController+Stripe_KeyboardAvoiding.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down