5

I have us that attempts to display itself above the keyboard and should not move once the keyboard is opened.

I can adjust where it displays but with the quicktype keyboard I can't determine the height of the keyboard unless I know if the quicktype is opened or close. Is there any way I can determine this?

madmik3
  • 6,975
  • 3
  • 38
  • 60
  • Take a look at my solution in the link: http://stackoverflow.com/questions/26213681/ios-8-keyboard-hides-my-textview/26226732#26226732 – newton_guima Oct 07 '14 at 00:33

1 Answers1

8

You should be using the keyboardWillShow: notification to adjust other views frames.

A notification is posted to keyboardWillShow: not only on becomeFirstResponder for a textView/Field but also when the user shows/hides the quick type keyboard.

once the keyboardWillShow: notification has been posted, the keyboard's frame can be captured by the 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) {

  }];
}
Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100
adamesgie
  • 89
  • 1
  • at this point in my code the keyboard has never shown and hence no notification. – madmik3 Sep 17 '14 at 19:37
  • This doesn't answer the question of the asker said about the quicktype area above the keyboard. Yes, the keyboard size is captured on launch, but the quicktype area isn't included in the launch. So when the user starts inputting text, the quicktype area is displayed. The quicktype area hides some of the screen. – D. Greg Dec 09 '16 at 22:34