Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Update, fixed in 7.1. No longer necessary.</h2> <hr> <p>For whatever reason, the animation curve reported on keyboard dismissal is incorrect. It seems to actually be 6 &lt;&lt; 16 instead of 7 &lt;&lt; 17.</p> <p>Here's what I do with <code>UIKeyboardWillChangeFrameNotification</code> to determine which animation curve to use.</p> <pre><code>NSDictionary *keyboardAnimationDetail = [notification userInfo]; CGRect keyboardEndFrameWindow = [keyboardAnimationDetail[UIKeyboardFrameEndUserInfoKey] CGRectValue]; double keyboardTransitionDuration = [keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // gives incorrect value of 7 on dismissal // UIViewAnimationCurve keyboardTransitionAnimationCurve = [keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] integerValue]; CGRect keyboardEndFrameView = [self.view convertRect:keyboardEndFrameWindow fromView:nil]; CGFloat newConstant = (self.view.frame.size.height - keyboardEndFrameView.origin.y); [UIView animateWithDuration:keyboardTransitionDuration delay:0.0f options:newConstant == 0 ? (6 &lt;&lt; 16) : (7 &lt;&lt; 16) animations:^{ self.tableView.contentInset = UIEdgeInsetsMake(self.tableView.contentInset.top, 0, self.view.frame.size.height - keyboardEndFrameView.origin.y + self.commentToolbar.frame.size.height, 0); self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(self.tableView.scrollIndicatorInsets.top, 0, self.view.frame.size.height - keyboardEndFrameView.origin.y + self.commentToolbar.frame.size.height, 0); self.commentViewToSuperviewBottomConstraint.constant = (self.view.frame.size.height - keyboardEndFrameView.origin.y); [self.view layoutIfNeeded]; } completion:^(__unused BOOL finished){ }]; </code></pre> <p>Basically I determine if the keyboard frame is hiding by seeing if the new y origin will be just outside our view's frame (<code>newConstant</code>). Then based on that I use either 6 or 7:</p> <p><code>newConstant == 0 ? (6 &lt;&lt; 16) : (7 &lt;&lt; 16)</code></p> <p>The rest is just adjusting my <code>tableView</code> <code>contentInset</code> and <code>scrollIndicatorInsets</code>, as well as changing the constant on the toolbar that is moving with the keyboard.</p>
    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.
 

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