From e45a445010134bc040b54b93c0085e5ee5734922 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Wed, 18 Sep 2019 09:21:51 +0930 Subject: [PATCH] Never ignore notifications if begin and end frames are different Fixes an issue where scrolling to the next field would not update the content insets to include the QuickType bar if it appears. --- .../UIScrollView+TPKeyboardAvoidingAdditions.m | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m b/TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m index c02bca24..adb9f376 100644 --- a/TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m +++ b/TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m @@ -52,16 +52,17 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification { state.animationDuration = [[info objectForKey:kUIKeyboardAnimationDurationUserInfoKey] doubleValue]; - CGRect keyboardRect = [self convertRect:[[info objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil]; - if (CGRectIsEmpty(keyboardRect)) { + CGRect beginKeyboardRect = [self convertRect:[[info objectForKey:_UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil]; + CGRect endKeyboardRect = [self convertRect:[[info objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil]; + if (CGRectIsEmpty(endKeyboardRect)) { return; } - if ( state.ignoringNotifications ) { + if ( CGRectEqualToRect(beginKeyboardRect, endKeyboardRect) && state.ignoringNotifications ) { return; } - state.keyboardRect = keyboardRect; + state.keyboardRect = endKeyboardRect; if ( !state.keyboardVisible ) { state.priorInset = self.contentInset; @@ -128,14 +129,15 @@ - (void)keyboardViewDisappear:(NSString *)animationID finished:(NSNumber *)finis } - (void)TPKeyboardAvoiding_keyboardWillHide:(NSNotification*)notification { - CGRect keyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil]; - if (CGRectIsEmpty(keyboardRect) && !self.keyboardAvoidingState.keyboardAnimationInProgress) { + CGRect beginKeyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil]; + CGRect endKeyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil]; + if (CGRectIsEmpty(beginKeyboardRect) && !self.keyboardAvoidingState.keyboardAnimationInProgress) { return; } TPKeyboardAvoidingState *state = self.keyboardAvoidingState; - if ( state.ignoringNotifications ) { + if ( CGRectEqualToRect(beginKeyboardRect, endKeyboardRect) && state.ignoringNotifications ) { return; }