J'ai corrigé ceci en twittant contentInset
sur le UITableView
lorsque le clavier apparaît ou disparaît.
- (void)registerForKeyboardNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasHidden:)
name:UIKeyboardDidHideNotification object:nil];
}
- (void)keyboardWasShown:(NSNotification *)aNotification {
CGRect keyboardBounds;
[[aNotification.userInfo valueForKey:UIKeyboardBoundsUserInfoKey] getValue: &keyboardBounds];
keyboardHeight = keyboardBounds.size.height;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
tableView.contentInset = UIEdgeInsetsMake(0, 0, keyboardBounds.size.height, 0);
[UIView commitAnimations];
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[items count] inSection:0]
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
}
- (void)keyboardWasHidden:(NSNotification *)aNotification {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
tableView.contentInset = UIEdgeInsetsZero;
[UIView commitAnimations];
}
appel registerForKeyboardNotifications
lorsque vous chargez le UITableView
, et tout le reste devrait fonctionner.
double possible de [Faire défiler UITextField ci-dessus du clavier dans un UITableViewCell sur un UIViewController régulier] (http: // stackoverflow .com/questions/15036519/scroll-uitextfield-above-keyboard-in-a-uitableviewcell-on-a-regular-uiviewcontro) –