TPKeyboardAvoiding icon indicating copy to clipboard operation
TPKeyboardAvoiding copied to clipboard

Support for keyboardWillChangeFrame needed

Open jclark71 opened this issue 11 years ago • 3 comments

AvoidingScrollView does not update insets for the keyboard frame changing. This might happen when moving from a textfield with a standard inputView (keyboard) to a different inputView (UIPicker, etc) which has a different height.

Since apple does not animate between keyboard frames, the fix is simply to add a notification observer for KeyboardWillChangeFrame, call a new method:

-(void)TPKeyboardAvoiding_keyboardWillChangeFrame:(NSNotification*)notification

which will basically be a clone of your method

  • (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification

except that you would now filter out cases that the keyboard is not shown yet

if (!state.keyboardVisible ) { return; }

and you would remove all animation logic.

jclark71 avatar Apr 09 '14 21:04 jclark71

Whoops. It was a little more complicated. There is some interference with they keyboardWillHide callback if using above method.

Instead, filter should be keyed off of if the supplied apple animation has a duration or not:

if ([[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue] != 0.0f ) {
    return;
}

Also, all adjustments to priorInsets and priorContentViews etc should be removed.

jclark71 avatar Apr 09 '14 22:04 jclark71

I'd love to see a pull request for this!

michaeltyson avatar Apr 10 '14 00:04 michaeltyson

I'd love to do this

NianJi avatar Apr 24 '14 09:04 NianJi