File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -1328,14 +1328,24 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
1328
1328
[self slk_postKeyboarStatusNotification: notification];
1329
1329
}
1330
1330
1331
- // 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.
1332
- [self .view slk_animateLayoutIfNeededWithDuration: duration
1333
- bounce: NO
1334
- options: (curve<<16 )|UIViewAnimationOptionLayoutSubviews|UIViewAnimationOptionBeginFromCurrentState
1335
- animations: ^{
1336
- [self slk_scrollToBottomIfNeeded ];
1337
- }
1338
- completion: NULL ];
1331
+ CGRect beginFrame = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue ];
1332
+ CGRect endFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue ];
1333
+ // Begin and end frames are the same when the keyboard is shown during navigation controller's push animation.
1334
+ // The animation happens in window coordinates (slides from right to left) but doesn't in the view controller's view coordinates.
1335
+ BOOL frameWillChange = !CGRectEqualToRect (beginFrame, endFrame);
1336
+
1337
+ if (frameWillChange) {
1338
+ // 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.
1339
+ [self .view slk_animateLayoutIfNeededWithDuration: duration
1340
+ bounce: NO
1341
+ options: (curve<<16 )|UIViewAnimationOptionLayoutSubviews|UIViewAnimationOptionBeginFromCurrentState
1342
+ animations: ^{
1343
+ [self slk_scrollToBottomIfNeeded ];
1344
+ }
1345
+ completion: NULL ];
1346
+ } else {
1347
+ [self slk_scrollToTopIfNeeded ];
1348
+ }
1339
1349
}
1340
1350
1341
1351
- (void )slk_didShowOrHideKeyboard : (NSNotification *)notification
You can’t perform that action at this time.
0 commit comments