@@ -892,6 +892,32 @@ - (void)setTextInputbarHidden:(BOOL)hidden animated:(BOOL)animated
892892 }
893893}
894894
895+ - (void )dismissTextInputbar : (BOOL )animated
896+ {
897+ if (self.keyboardHC .constant == 0 ) {
898+ return ;
899+ }
900+
901+ __weak typeof (self) weakSelf = self;
902+
903+ [self slk_hideAutoCompletionViewIfNeeded ];
904+
905+ void (^animations)() = ^void (){
906+
907+ weakSelf.keyboardHC .constant = 0.0 ;
908+ weakSelf.scrollViewHC .constant = [weakSelf slk_appropriateScrollViewHeight ];
909+
910+ [weakSelf.view layoutIfNeeded ];
911+ };
912+
913+ if (animated) {
914+ [UIView animateWithDuration: 0.25 animations: animations completion: nil ];
915+ }
916+ else {
917+ animations ();
918+ }
919+ }
920+
895921
896922#pragma mark - Private Methods
897923
@@ -1160,20 +1186,6 @@ - (void)slk_enableTypingSuggestionIfNeeded
11601186 [self .textView setTypingSuggestionEnabled: enable];
11611187}
11621188
1163- - (void )slk_dismissTextInputbarIfNeeded
1164- {
1165- if (self.keyboardHC .constant == 0 ) {
1166- return ;
1167- }
1168-
1169- self.keyboardHC .constant = 0.0 ;
1170- self.scrollViewHC .constant = [self slk_appropriateScrollViewHeight ];
1171-
1172- [self slk_hideAutoCompletionViewIfNeeded ];
1173-
1174- [self .view layoutIfNeeded ];
1175- }
1176-
11771189- (void )slk_detectKeyboardStatesInNotification : (NSNotification *)notification
11781190{
11791191 // Tear down
@@ -1343,7 +1355,7 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
13431355 return ;
13441356 }
13451357 else if (![self forceTextInputbarAdjustmentForResponder: currentResponder]) {
1346- return [self slk_dismissTextInputbarIfNeeded ];
1358+ return [self dismissTextInputbar: NO ];
13471359 }
13481360 }
13491361
0 commit comments