@@ -495,12 +495,12 @@ - (SLKKeyboardStatus)slk_keyboardStatusForNotification:(NSNotification *)notific
495
495
return -1 ;
496
496
}
497
497
498
- - (BOOL )slk_isIllogicalKeyboardStatus : (SLKKeyboardStatus)status
498
+ - (BOOL )slk_isIllogicalKeyboardStatus : (SLKKeyboardStatus)newStatus
499
499
{
500
- if ((self.keyboardStatus == 0 && status == 1 ) ||
501
- (self.keyboardStatus == 1 && status == 2 ) ||
502
- (self.keyboardStatus == 2 && status == 3 ) ||
503
- (self.keyboardStatus == 3 && status == 0 )) {
500
+ if ((self.keyboardStatus == SLKKeyboardStatusDidHide && newStatus == SLKKeyboardStatusWillShow ) ||
501
+ (self.keyboardStatus == SLKKeyboardStatusWillShow && newStatus == SLKKeyboardStatusDidShow ) ||
502
+ (self.keyboardStatus == SLKKeyboardStatusDidShow && newStatus == SLKKeyboardStatusWillHide ) ||
503
+ (self.keyboardStatus == SLKKeyboardStatusWillHide && newStatus == SLKKeyboardStatusDidHide )) {
504
504
return NO ;
505
505
}
506
506
return YES ;
@@ -915,6 +915,7 @@ - (void)slk_handlePanGestureRecognizer:(UIPanGestureRecognizer *)gesture
915
915
CGFloat keyboardMaxY = CGRectGetHeight (SLKKeyWindowBounds ());
916
916
CGFloat keyboardMinY = keyboardMaxY - CGRectGetHeight (keyboardView.frame );
917
917
918
+
918
919
// Skips this if it's not the expected textView.
919
920
// Checking the keyboard height constant helps to disable the view constraints update on iPad when the keyboard is undocked.
920
921
// Checking the keyboard status allows to keep the inputAccessoryView valid when still reacing the bottom of the screen.
@@ -1155,9 +1156,6 @@ - (void)slk_dismissTextInputbarIfNeeded
1155
1156
1156
1157
[self slk_hideAutoCompletionViewIfNeeded ];
1157
1158
1158
- // Forces the keyboard status change
1159
- [self slk_updateKeyboardStatus: SLKKeyboardStatusDidHide];
1160
-
1161
1159
[self .view layoutIfNeeded ];
1162
1160
}
1163
1161
@@ -1307,6 +1305,19 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
1307
1305
return ;
1308
1306
}
1309
1307
1308
+ SLKKeyboardStatus status = [self slk_keyboardStatusForNotification: notification];
1309
+
1310
+ // Skips if it's the current status
1311
+ if (self.keyboardStatus == status) {
1312
+ return ;
1313
+ }
1314
+
1315
+ // Updates and notifies about the keyboard status update
1316
+ if ([self slk_updateKeyboardStatus: status]) {
1317
+ // Posts custom keyboard notification, if logical conditions apply
1318
+ [self slk_postKeyboarStatusNotification: notification];
1319
+ }
1320
+
1310
1321
// Skips this it's not the expected textView and shouldn't force adjustment of the text input bar.
1311
1322
// This will also dismiss the text input bar if it's visible, and exit auto-completion mode if enabled.
1312
1323
if (![self .textView isFirstResponder ]) {
@@ -1321,13 +1332,6 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
1321
1332
}
1322
1333
}
1323
1334
1324
- SLKKeyboardStatus status = [self slk_keyboardStatusForNotification: notification];
1325
-
1326
- // Skips if it's the current status
1327
- if (self.keyboardStatus == status) {
1328
- return ;
1329
- }
1330
-
1331
1335
// Programatically stops scrolling before updating the view constraints (to avoid scrolling glitch).
1332
1336
if (status == SLKKeyboardStatusWillShow) {
1333
1337
[self .scrollViewProxy slk_stopScrolling ];
@@ -1342,11 +1346,6 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
1342
1346
self.keyboardHC .constant = [self slk_appropriateKeyboardHeightFromNotification: notification];
1343
1347
self.scrollViewHC .constant = [self slk_appropriateScrollViewHeight ];
1344
1348
1345
- // Updates and notifies about the keyboard status update
1346
- if ([self slk_updateKeyboardStatus: status]) {
1347
- // Posts custom keyboard notification, if logical conditions apply
1348
- [self slk_postKeyboarStatusNotification: notification];
1349
- }
1350
1349
1351
1350
NSInteger curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue ];
1352
1351
NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue ];
@@ -1406,6 +1405,12 @@ - (void)slk_didShowOrHideKeyboard:(NSNotification *)notification
1406
1405
return ;
1407
1406
}
1408
1407
1408
+ // Updates and notifies about the keyboard status update
1409
+ if ([self slk_updateKeyboardStatus: status]) {
1410
+ // Posts custom keyboard notification, if logical conditions apply
1411
+ [self slk_postKeyboarStatusNotification: notification];
1412
+ }
1413
+
1409
1414
// After showing keyboard, check if the current cursor position could diplay autocompletion
1410
1415
if ([self .textView isFirstResponder ] && status == SLKKeyboardStatusDidShow && !self.isAutoCompleting ) {
1411
1416
@@ -1415,12 +1420,6 @@ - (void)slk_didShowOrHideKeyboard:(NSNotification *)notification
1415
1420
});
1416
1421
}
1417
1422
1418
- // Updates and notifies about the keyboard status update
1419
- if ([self slk_updateKeyboardStatus: status]) {
1420
- // Posts custom keyboard notification, if logical conditions apply
1421
- [self slk_postKeyboarStatusNotification: notification];
1422
- }
1423
-
1424
1423
// Very important to invalidate this flag after the keyboard is dismissed or presented, to start with a clean state next time.
1425
1424
self.movingKeyboard = NO ;
1426
1425
}
0 commit comments