Sunday, October 11, 2009

iPhone dev Stupidity 37: Keyboard Size

If you don't want to hard code the keyboard size or position

From here:

  1. [[NSNotificationCenter defaultCenter] addObserver:self  
  2.                                          selector:@selector(keyboardNotification:)  
  3.                                              name:UIKeyboardWillShowNotification  
  4.                                            object:nil];  

The keyboardNotification method looks like this:
  1. - (void)keyboardNotification:(NSNotification*)notification {  
  2.     NSDictionary *userInfo = [notification userInfo];  
  3.     NSValue *keyboardBoundsValue = [userInfo objectForKey:UIKeyboardBoundsUserInfoKey];  
  4.     [keyboardBoundsValue getValue:&keyboardBounds];  
  5. }  


No comments: