Skip to content

Commit

Permalink
Fixing keyboard issues on iOS 12
Browse files Browse the repository at this point in the history
  • Loading branch information
umrysh authored May 8, 2019
1 parent 62cfacc commit 28dc536
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/ios/CDVKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,28 @@ - (void)shrinkViewKeyboardWillChangeFrame:(NSNotification*)notif
// The webview should always be able to return to full size
CGRect keyboardIntersection = CGRectIntersection(screen, keyboard);
if (CGRectContainsRect(screen, keyboardIntersection) && !CGRectIsEmpty(keyboardIntersection) && _shrinkView && self.keyboardIsVisible) {
screen.size.height -= keyboardIntersection.size.height;
self.webView.scrollView.scrollEnabled = !self.disableScrollingInShrinkView;
// I'm sure there's a better way...
if (@available(iOS 12, *)) {
self.webView.scrollView.scrollEnabled = !self.disableScrollingInShrinkView; // Order intentionally swapped.
screen.size.height -= keyboardIntersection.size.height;

CGSize revisedSize = CGSizeMake(self.webView.scrollView.frame.size.width, self.webView.scrollView.frame.size.height - keyboard.size.height);
self.webView.scrollView.contentSize = revisedSize;
}
else {
screen.size.height -= keyboardIntersection.size.height;
self.webView.scrollView.scrollEnabled = !self.disableScrollingInShrinkView;
}
}

// A view's frame is in its superview's coordinate system so we need to convert again
self.webView.frame = [self.webView.superview convertRect:screen fromView:self.webView];

// I'm sure there's a better way...
if (@available(iOS 12, *)) {
CGSize revisedSize = CGSizeMake(self.webView.frame.size.width, self.webView.frame.size.height - keyboard.size.height);
self.webView.scrollView.contentSize = revisedSize;
}
}

#pragma mark UIScrollViewDelegate
Expand Down

0 comments on commit 28dc536

Please sign in to comment.