TPKeyboardAvoiding
TPKeyboardAvoiding copied to clipboard
Support for keyboardWillChangeFrame needed
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.
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.
I'd love to see a pull request for this!
I'd love to do this