Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } - (void)keyboardWillShow:(NSNotification *)aNotification { CGRect keyboardBounds; [[aNotification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &amp;keyboardBounds]; CGFloat keyboardHeight; switch ([UIApplication sharedApplication].statusBarOrientation) { case UIInterfaceOrientationPortrait: case UIInterfaceOrientationPortraitUpsideDown: keyboardHeight = keyboardBounds.size.height; break; case UIInterfaceOrientationLandscapeLeft: case UIInterfaceOrientationLandscapeRight: keyboardHeight = keyboardBounds.size.width; break; } NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; CGRect rect = table.frame; rect.size.height -= keyboardHeight; [UIView beginAnimations:@"ResizeForKeyboardShow" context:nil]; [UIView setAnimationDuration:animationDuration]; table.frame = rect; [UIView commitAnimations]; } - (void)keyboardWillHide:(NSNotification *)aNotification { CGRect keyboardBounds; [[aNotification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &amp;keyboardBounds]; CGFloat keyboardHeight; switch ([UIApplication sharedApplication].statusBarOrientation) { case UIInterfaceOrientationPortrait: case UIInterfaceOrientationPortraitUpsideDown: keyboardHeight = keyboardBounds.size.height; break; case UIInterfaceOrientationLandscapeLeft: case UIInterfaceOrientationLandscapeRight: keyboardHeight = keyboardBounds.size.width; break; } NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; CGRect rectTable = table.frame; rectTable.size.height += keyboardHeight; [UIView beginAnimations:@"ResizeForKeyboard" context:nil]; [UIView setAnimationDuration:animationDuration]; table.frame = rectTable; [UIView commitAnimations]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload