3

I get the keyboard height like this:

- (void)keyboardNotification:(NSNotification*)notification
{
    NSDictionary* keyboardInfo = [notification userInfo];
    NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue];
}

Now, I have the keyboard height. But without the autocorrection height:

enter image description here

If the UITextAutocorrectionType is YES / NO the keyboard height stay the same.

How can I get the Keyboard autocorrection height?

Thanks in advance.

gran33
  • 12,421
  • 9
  • 48
  • 76
  • 1
    possible duplicate of [can't get correct value of keyboard height in iOS8](http://stackoverflow.com/questions/25874975/cant-get-correct-value-of-keyboard-height-in-ios8) – Vizllx May 25 '15 at 08:03
  • Have you tried converting the rect to the view coordinates? Like `keyboardFrameBeginRect = [myView convertRect: keyboardFrameBeginRect fromView:nil];` – Lefteris May 25 '15 at 08:05

2 Answers2

3

Use this :

 CGRect keyboardBounds;
        [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardBounds];
   // Need to translate the bounds to account for rotation.
  keyboardBounds = [self.view convertRect:keyboardBounds toView:nil];
Jen Jose
  • 3,995
  • 2
  • 19
  • 36
0

Use UIKeyboardWillChangeFrameNotification. This will be called every time when suggestion bar shows or hides.

NSConcreteNotification 0xc472900 {name = UIKeyboardWillChangeFrameNotification; userInfo = {
    UIKeyboardAnimationCurveUserInfoKey = 7;
    UIKeyboardAnimationDurationUserInfoKey = "0.25";
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}";
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 588}";
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 372}";
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 216}}";
    UIKeyboardFrameChangedByUserInteraction = 0;
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 264}, {320, 216}}";
}}
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
  • Thanks man, but how does this help me? Maybe I miss something, I asked about the keybord height + autocorrction height, In your answer I see the problem :/ the keyboard height only (without autocorrection height) – gran33 May 25 '15 at 08:52
  • If autocorrection bar is there, It will return that height also. – Nirav Gadhiya May 25 '15 at 09:05
  • @NiravGadhiya it doesn't work that way, or I don't get how to find autocorrection height – Dmitry Petukhov Apr 10 '18 at 06:10