TPKeyboardAvoiding icon indicating copy to clipboard operation
TPKeyboardAvoiding copied to clipboard

Animated change of contentOffset for case with changing keyboard height

Open kohtenko opened this issue 10 years ago • 3 comments

In case you got several UITextField's with different keyboard height (for example username and secure password without iOS hints) switching between them will be a bit jerky. Animation of setContentOffset doesn't affect behaviour in other situation, but fixes this.

kohtenko avatar Aug 19 '15 11:08 kohtenko

This seems to cause a little bounce in the keyboard hide animation when contentInsets is not zero - here's the original behaviour:

https://dl.dropboxusercontent.com/u/6956432/prior.mov

And here's the behaviour with this change:

https://dl.dropboxusercontent.com/u/6956432/new.mov

...Not that I don't think the bounce is kinda cute, but I don't think it's quite right. If the problem you describe happens only when switching between existing fields, could we perhaps only have this new behaviour when the keyboard is already visible? (state.keyboardVisible = YES at method entry)

michaeltyson avatar Aug 20 '15 01:08 michaeltyson

...Incidentally, to reproduce that, add something like:

self.scrollView.contentInset = UIEdgeInsetsMake(100, 0, 100, 0);

to TPKAScrollViewController.m:23 (at the start of viewDidLoad)

michaeltyson avatar Aug 20 '15 02:08 michaeltyson

You're right, problem has been a bit deeper. Check out this commit d56b5de98a5671323078f4d14d8b0f96d16c716f.

  • Added one secureTextEntry in demo project, so you can make sure it works perfectly.
  • Added one more check in TPKeyboardAvoiding_keyboardWillShow, cause we don't want it invoked when keyboard changes frame to 'out of screen'
  • Bounces occurred because UIKeyboardAnimationCurveUserInfoKey and UIKeyboardAnimationDurationUserInfoKey of NSNotification empty while keyboard changes frame

You closed this PR, so I can't add this commit here. I believe if you reopen it - commit will appears here automatically

kohtenko avatar Aug 20 '15 07:08 kohtenko