1

I want to get the size of the keyboard, and I do this as follows:

- (void)viewDidLoad
{
    ....

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)  name:UIKeyboardWillShowNotification object:nil];

    ....
}

//I can get the size here
- (void)keyboardWillShow:(NSNotification *)notification 
{

    NSDictionary *userInfo = [notification userInfo];
    NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
}

But now, I want to get the size before the keyboard is showed (before the "keyboardWillShow" method is called). How can I do it?

itenyh
  • 1,921
  • 2
  • 23
  • 38
  • check this link: http://stackoverflow.com/questions/4213878/what-is-the-height-of-ipads-onscreen-keyboard – Amit Apr 24 '13 at 06:47

2 Answers2

1

Actually - (void)keyboardWillShow:(NSNotification *)notification; method get fired, before keyboard get show.

Mani
  • 17,549
  • 13
  • 79
  • 100
0

As you can see from one of the answers here, it really depends on the type of keyboard, plus the device you are on. You should also keep in mind that in the future, the keyboard can change, so you should rely on the dictionary that is passed on the NSNotification for the exact size of it.

Community
  • 1
  • 1
Rui Peres
  • 25,741
  • 9
  • 87
  • 137