Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Animate views when switching from the a keyboard to a custom input view. - #416

Merged
dzenbot merged 1 commit into
slackhq:masterfrom
cyhsutw:change-keyboard-frame-animation
Mar 23, 2016
Merged

Animate views when switching from the a keyboard to a custom input view.#416
dzenbot merged 1 commit into
slackhq:masterfrom
cyhsutw:change-keyboard-frame-animation

Conversation

@cyhsutw

@cyhsutw cyhsutw commented Mar 15, 2016

Copy link
Copy Markdown
Contributor

Hello,

I found there's a "jump" when setting the inputView property of the text view:

Without Animation

It looks like the value of UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey are the same when reloadInputViews is called after setting a custom inputView.

So I add a condition to check if the height of the keyboard changed.

This is the result after the modification:

With Animation

Looking forward to your feedback.

// The animation happens in window coordinates (slides from right to left) but doesn't in the view controller's view coordinates.
if (!CGRectEqualToRect(beginFrame, endFrame))
// Second condition: check if the height of the keyboard changed.
if (!CGRectEqualToRect(beginFrame, endFrame) || fabs(preKeyboardHeight - self.keyboardHC.constant) >= FLT_EPSILON)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Is the difference really small as FLT_EPSILON?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of my habit when dealing with floating point numbers. 😛
As you mentioned, a direct comparison will do the work and there should not affect anything at UI level.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello
how you put custom view in keyboard place ?!

@cyhsutw cyhsutw Nov 3, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SLAMAKA You can do this by setting inputView to any kind of UIResponder.

Reference: https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/InputViews/InputViews.html

Since this is not relevant to this pull request, could we move the discussion to a private email thread, feel free to drop me a message at m@cyhsu.me

Thanks.

@dzenbot
dzenbot merged commit b6dc603 into slackhq:master Mar 23, 2016
@dzenbot

dzenbot commented Mar 23, 2016

Copy link
Copy Markdown

Looks good! Thanks.

@cyhsutw

cyhsutw commented Mar 23, 2016

Copy link
Copy Markdown
Contributor Author

@dzenbot Thank you! 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants