title: Logic For Moving Text Field Above Keyboard On Tap
body: <p>Right now, I have basic code for moving the textfield above the keyboard when you start editing. However, the size of the textfield varies based on device and orientation. So, I wrote a crude way of doing it, which doesn't stay consistently right above the keyboard, but instead will go up further when you rotate it, and so it doesn't look as professional as I would like.</p>
  
  <p>The basic sense of my question is if there is a logic for getting the size of the keyboard based on device and orientation and using that value automatically and hopefully faster than this. </p>
  
  <p>If that is the best way, please let me know. Otherwise, please provide input. Here is the code that I have. 
  (This is just the move-up code, not the move down code, in order to prevent taking up too much space)</p>
  
  <pre><code>- (void)textFieldDidBeginEditing:(UITextField *)textField { 
  
      //Get Device Type
      NSString *deviceType = [[UIDevice currentDevice] model];
  
      //Animate Text Field
      [UIView beginAnimations:nil context:NULL];
      [UIView setAnimationDelegate:self];
      [UIView setAnimationDuration:0.4];
      [UIView setAnimationBeginsFromCurrentState:YES];
  
      if ([deviceType isEqualToString:@"iPhone"]) {
  
          //Size For iPhone
          googleBar.frame = CGRectMake(googleBar.frame.origin.x - 62.0, (googleBar.frame.origin.y - 210.0), googleBar.frame.size.width + 120.0, googleBar.frame.size.height);
  
      } else if ([deviceType isEqualToString:@"iPad"]) {
  
          //Size for iPad
          googleBar.frame = CGRectMake(googleBar.frame.origin.x - 62.0, (googleBar.frame.origin.y - 320.0), googleBar.frame.size.width + 120.0, googleBar.frame.size.height);
  
      } else if ([deviceType isEqualToString:@"iPod touch"]) {
  
          //Size For iPod Touch
          googleBar.frame = CGRectMake(googleBar.frame.origin.x - 62.0, (googleBar.frame.origin.y - 210.0), googleBar.frame.size.width + 120.0, googleBar.frame.size.height);
  
      } 
  
      [UIView commitAnimations];
  
  } 
  </code></pre>