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

Commit b6dc603

Browse files
author
Ignacio Romero Zurbuchen
committed
Merge pull request #416 from cyhsutw/change-keyboard-frame-animation
Animate views when switching from the a keyboard to a custom input view.
2 parents e1afa41 + 7885606 commit b6dc603

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Source/SLKTextViewController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,9 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
13651365
[self slk_hideAutoCompletionViewIfNeeded];
13661366
}
13671367

1368+
// store the previous keyboard height
1369+
CGFloat preKeyboardHeight = self.keyboardHC.constant;
1370+
13681371
// Updates the height constraints' constants
13691372
self.keyboardHC.constant = [self slk_appropriateKeyboardHeightFromNotification:notification];
13701373
self.scrollViewHC.constant = [self slk_appropriateScrollViewHeight];
@@ -1390,7 +1393,8 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
13901393

13911394
// Begin and end frames are the same when the keyboard is shown during navigation controller's push animation.
13921395
// The animation happens in window coordinates (slides from right to left) but doesn't in the view controller's view coordinates.
1393-
if (!CGRectEqualToRect(beginFrame, endFrame))
1396+
// Second condition: check if the height of the keyboard changed.
1397+
if (!CGRectEqualToRect(beginFrame, endFrame) || fabs(preKeyboardHeight - self.keyboardHC.constant) >= FLT_EPSILON)
13941398
{
13951399
// Only for this animation, we set bo to bounce since we want to give the impression that the text input is glued to the keyboard.
13961400
[self.view slk_animateLayoutIfNeededWithDuration:duration

0 commit comments

Comments
 (0)