简体   繁体   English

为什么显示键盘时UITableVIew向下滚动而不向上滚动?

[英]Why does the UITableVIew scroll down but not up when keyboard is shown?

I have textViews in a tableView . 我有textViewstableView When textViews (towards the bottom of the tableView ) get selected the keyboard pops up, and hides the textView , and you can't scroll down either. 当选择textViews (朝向tableView的底部)时,键盘会弹出并隐藏textView ,您也无法向下滚动。 So I added the following code: 所以我添加了以下代码:

- (void)keyboardWasShown:(NSNotification*)aNotification
{
    NSDictionary* info = [aNotification userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

    UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
    myTableView.contentInset = contentInsets;
    myTableView.scrollIndicatorInsets = contentInsets;

    CGRect aRect = self.view.frame;
    aRect.size.height -= kbSize.height;
    if (!CGRectContainsPoint(aRect, activeField.frame.origin) ) {
        [self.myTabelView scrollRectToVisible:activeField.frame animated:YES];
    }
}

I now have the opposite problem. 我现在有相反的问题。 When the keyboard does show, towrad the top doesn't show, and it's not possible to scroll all the way up either. 当键盘确实显示时,拖曳的顶部也不会显示,也无法一直向上滚动。

Hi and did you try to use TPKeyboardAvoiding ? 嗨,您是否尝试使用TPKeyboardAvoiding? I use it to solve such cases without to need to code anything... You can try it as CocoaPod quickly. 我用它来解决这种情况,而无需编写任何代码...您可以像CocoaPod一样快速尝试它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM