Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView won't scroll after keyboard is hidden
    text
    copied!<p>I have a UITableView with custom cells. Based on an answer to this <a href="https://stackoverflow.com/questions/594181/uitableview-and-keyboard-scrolling-problem/4430737#4430737">question</a> I am resizing the view when to accommodate the keyboard and resizing when the keyboard is dismissed. After dismissing the keyboard the table view no longer scrolls.</p> <p>These are the methods called when showing and hiding the keyboard:</p> <pre><code>-(void)keyboardWillShow:(NSNotification *)note { NSDictionary* userInfo = [note userInfo]; NSValue* keyboardFrameValue = [userInfo objectForKey:@"UIKeyboardBoundsUserInfoKey"]; if (!keyboardFrameValue) { keyboardFrameValue = [userInfo objectForKey:@"UIKeyboardFrameEndUserInfoKey"]; } // Reduce the tableView height by the part of the keyboard that actually covers the tableView CGRect windowRect = [[UIApplication sharedApplication] keyWindow].bounds; CGRect viewRectAbsolute = [myTableView convertRect:myTableView.bounds toView:[[UIApplication sharedApplication] keyWindow]]; CGRect frame = myTableView.frame; frame.size.height -= [keyboardFrameValue CGRectValue].size.height - CGRectGetMaxY(windowRect) + CGRectGetMaxY(viewRectAbsolute); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:[[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]]; [UIView setAnimationCurve:[[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]]; myTableView.frame = frame; [UIView commitAnimations]; UITableViewCell *textFieldCell = (id)((UITextField *)self.textFieldBeingEdited).superview.superview; NSIndexPath *textFieldIndexPath = [myTableView indexPathForCell:textFieldCell]; [NSObject cancelPreviousPerformRequestsWithTarget:self]; [myTableView scrollToRowAtIndexPath:textFieldIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; } -(void)keyboardWillHide:(NSNotification *)note { CGRect keyboardRect = [[[note userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; NSTimeInterval animationDuration = [[[note userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; CGRect frame = self.myTableView.frame; frame.size.height += keyboardRect.size.height + 49; [UIView beginAnimations:@"ResizeForKeyboard" context:nil]; [UIView setAnimationDuration:animationDuration]; self.myTableView.frame = frame; [UIView commitAnimations]; myTableView.scrollEnabled = YES; } </code></pre> <p>Any ideas what I am missing?</p>
 

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