title: iPhone SDK: TextView, Keyboard in Landscape mode
body: <p>How do I make sure that the textview is shown and the keyboard is not obscuring the textview, while in landscape.</p>
  
  <p>Using UICatalog I created a TextViewController which works. In it there are two methods for calling the keyboard and making sure that textView is positioned above the keyboard. his just works great in Portrait mode.</p>
  
  <p>I got the Landscape mode working, but on the textView is still being put to the top of the iPhone to compensate for the keyboard in portrait mode.</p>
  
  <p>I changed the methods for showing the keyboards.</p>
  
  <p>Below is the code for this methods: (I will just let see the code for show, since the hide code will be the reverse..</p>
  
  <pre><code>- (void)keyboardWillShow:(NSNotification *)aNotification 
  {
   UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
   if (orientation == UIInterfaceOrientationPortrait) {
     // the keyboard is showing so resize the table's height
    CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
    NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    CGRect frame = self.view.frame;
    frame.size.height -= keyboardRect.size.height;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    self.view.frame = frame;
    [UIView commitAnimations];
   } else if (orientation == UIInterfaceOrientationLandscapeLeft) {
    NSLog(@"Left"); // Verijderen later
    CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
    NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    CGRect frame = self.view.frame;
    frame.size.width -= keyboardRect.size.height;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    self.view.frame = frame;
    [UIView commitAnimations];
   } else if (orientation == UIInterfaceOrientationLandscapeRight){
    NSLog(@"Right"); // verwijderen later.
    CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
    NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    CGRect frame = self.view.frame;
    frame.size.width -= keyboardRect.size.width;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    self.view.frame = frame;
    [UIView commitAnimations];
   }
  
  }
  </code></pre>
  
  <p>I know that I have to change the line <code>frame.size.height -= keyboardRect.size.height</code> but I do not seem to get it working.</p>
  
  <p>I tried <code>frame.size.width -= keyboardRect.size.height</code> that did not work. Losing the keyboardRect and frame all together work, however off course the keyboard obscures the textview........</p>