Keyboard detection QuickType iOS 8 opens or closes without notification

I have we who are trying to display themselves above the keyboard and should not move after opening the keyboard.

I can configure where it is displayed, but with a keyboard of fast type I cannot determine the height of the keyboard if I do not know if the quicktype type is open or closed. Can this be determined?

+5
source share
1 answer

You should use the keyboardWillShow : notification to customize other presentation frames.

A notification is sent to keyboardWillShow : not only to becomeFirstResponder for the text field / field, but also when the user shows / hides the keyboard of a quick type.

after the keyboardWillShow : notification is sent, the keyboard frame can be captured by UIKeyboardFrameEndUserInfoKey in the notification object.

An example of a textView that adjusts its frame based on the keyboard:

 - (void)keyboardWillShow:(NSNotification *)notification { CGRect keyboardRect = [[[notification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; NSTimeInterval duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; UIViewAnimationCurve curve = [[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]; [UIView animateWithDuration:duration animations:^{ [UIView setAnimationCurve:curve]; self.textViewVisualEffectView.frame = CGRectMake(self.textViewVisualEffectView.origin.x, self.view.height - keyboardRect.size.height - self.textViewVisualEffectView.height, self.textViewVisualEffectView.width, self.textViewVisualEffectView.height); } completion:^(BOOL finished) { }]; } 
+8
source

Source: https://habr.com/ru/post/1202799/


All Articles