Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The approach I took is to add a view which follows the size of the keyboard. Add it below your tableview, or text input or whatever and it will push things up when the keyboard appears.</p> <p>This is how I set up the view hierarchy:</p> <pre><code>NSDictionary *views = @{@"chats": self.chatsListView, @"reply": self.replyBarView, @"fakeKeyboard":self.fakeKeyboardView}; [self.view addVisualConstraints:@"V:|-30-[chats][reply][fakeKeyboard]|" views:views]; </code></pre> <p>And then the key bits of the keyboard-size-following view look like this:</p> <pre><code>- (void)keyboardWillShow:(NSNotification *)notification { // Save the height of keyboard and animation duration NSDictionary *userInfo = [notification userInfo]; CGRect keyboardRect = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; self.desiredHeight = CGRectGetHeight(keyboardRect); self.duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue]; [self animateSizeChange]; } - (void)keyboardWillHide:(NSNotification *)notification { self.desiredHeight = 0.0f; [self animateSizeChange]; } - (CGSize)intrinsicContentSize { return CGSizeMake(UIViewNoIntrinsicMetric, self.desiredHeight); } - (void)animateSizeChange { [self invalidateIntrinsicContentSize]; // Animate transition [UIView animateWithDuration:self.duration animations:^{ [self.superview layoutIfNeeded]; }]; } </code></pre> <p>The nice thing about letting this particular view handle its resizing is that you can let the view controller ignore it, and you can also re-use this view any place in your app you want to shift everything up.</p> <p>The full file is here: <a href="https://gist.github.com/shepting/6025439" rel="nofollow">https://gist.github.com/shepting/6025439</a></p>
    singulars
    1. This table or related slice is empty.
    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. 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