title: Getting UIKeyboard Height When TextField Shows
body: <p>I have a couple UITextFields that will be hidden by the keyboard when it pops up, so I implemented the <code>UIKeyboardWillShowNotification</code> and <code>UIKeyboardWillHideNotification</code> and sent them to their respective methods:</p>
  
  <pre><code>- (void)keyboardWillShow:(NSNotification*)notification
  {
      CGFloat height = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
      keyBoardHeight = height;
  }
  
  - (void)keyboardWillHide:(NSNotification*)notification
  {
      CGFloat height = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
      keyBoardHeight = height;
  }
  </code></pre>
  
  <p>I then have my textfields delegating to this method:</p>
  
  <pre><code>//TextFieldDelegate
  - (void)textFieldDidBeginEditing:(UITextField *)textField
  {
      float keyboardOffset = [self offsetForKeyboard:textField.frame.origin.y withHeight:textField.frame.size.height];
      NSLog(@"%f, %f", keyBoardHeight, keyboardOffset);
  
      [UIView beginAnimations:nil context:nil];
      [UIView setAnimationDuration:0.1];
      self.view.frame = [Global rect:self.view.frame withNewY:-[self offsetForKeyboard:textField.frame.origin.y withHeight:textField.frame.size.height]];
      [UIView commitAnimations];
  }
  </code></pre>
  
  <p>The code runs properly, but when I run the code, the <code>keyboardWillShow:</code> method runs <strong>after</strong> the <code>textFieldDidBeginEditing:</code> method. Because of this, <code>keyboardHeight</code> is set to 0 the first time the code runs, and so the offset I calculate is way off.</p>
  
  <p>How can I make the <code>keyboardWillShow:</code> method run <strong>before</strong> the <code>textFieldDidBeginEditing:</code> method? Is there another delegate method that I can use instead?</p>