Iphone UITableView赢得';隐藏键盘后不能滚动

Iphone UITableView赢得';隐藏键盘后不能滚动,iphone,objective-c,ios,Iphone,Objective C,Ios,我有一个自定义单元格的UITableView。基于对这个问题的回答,我正在调整视图的大小以适应键盘,并在键盘关闭时调整视图的大小。关闭键盘后,表格视图不再滚动 以下是显示和隐藏键盘时调用的方法: -(void)keyboardWillShow:(NSNotification *)note { NSDictionary* userInfo = [note userInfo]; NSValue* keyboardFrameValue = [userInfo objectForKe

我有一个自定义单元格的UITableView。基于对这个问题的回答,我正在调整视图的大小以适应键盘,并在键盘关闭时调整视图的大小。关闭键盘后,表格视图不再滚动

以下是显示和隐藏键盘时调用的方法:

-(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;
}

你知道我遗漏了什么吗?

我用了你链接到的同一个问题来解决同一个问题。虽然我不记得我最终使用了多少原始代码,但它对我来说工作得很好

对于您的问题,(尽管我想您已经尝试过这个),首先想到的是查看代码,看看您是否在做

self.tableView.scrollEnabled = NO;

如果是这样的话,你应该确认你在某个地方有一个对应的语句,然后把它设置回YES;事实上,您可以在keyboardWillHide中将scrollEnabled设置为YES,以测试这是否有帮助。

有问题的行是:

frame.size.height += keyboardRect.size.height + 49;
应该是:

frame.size.height += keyboardRect.size.height - self.navigationController.toolbar.frame.size.height;

是的,我试过在keyboardWillHide中设置scrollEnabled=Yes。这似乎没有帮助。