Skip to content
This repository has been 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
merged 1 commit into from
Mar 23, 2016
Merged

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

merged 1 commit into from
Mar 23, 2016

Conversation

cyhsutw
Copy link
Contributor

@cyhsutw cyhsutw commented Mar 15, 2016

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.

@@ -1397,7 +1400,8 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification

// Begin and end frames are the same when the keyboard is shown during navigation controller's push animation.
// 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

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
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

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 ?!

Copy link
Contributor Author

@cyhsutw cyhsutw Nov 3, 2016

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
Copy link

dzenbot commented Mar 23, 2016

Looks good! Thanks.

@cyhsutw
Copy link
Contributor Author

cyhsutw commented Mar 23, 2016

@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