Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try the next code. In this case table view lays out at the bottom edge of the screen.</p> <pre><code>- (void)keyboardWillShow:(NSNotification *)notification { // UIKeyboardWillShowNotification NSDictionary *info = [notification userInfo]; NSValue *keyboardFrameValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey]; NSTimeInterval animationDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; CGRect keyboardFrame = [keyboardFrameValue CGRectValue]; BOOL isPortrait = UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation); CGFloat keyboardHeight = isPortrait ? keyboardFrame.size.height : keyboardFrame.size.width; // constrBottom is a constraint defining distance between bottom edge of tableView and bottom edge of its superview constrBottom.constant = keyboardHeight; // or constrBottom.constant = -keyboardHeight - in case if you create constrBottom in code (NSLayoutConstraint constraintWithItem:...:toItem:...) and set views in inverted order [UIView animateWithDuration:animationDuration animations:^{ [tableView layoutIfNeeded]; }]; } - (void)keyboardWillHide:(NSNotification *)notification { // UIKeyboardWillHideNotification NSDictionary *info = [notification userInfo]; NSTimeInterval animationDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; constrBottom.constant = 0; [UIView animateWithDuration:animationDuration animations:^{ [tableView layoutIfNeeded]; }]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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