【问题标题】:Height from keyboard to navigationbar从键盘到导航栏的高度
【发布时间】:2016-06-02 10:07:18
【问题描述】:

我需要创建一个从键盘 y 位置到导航栏高度的表格视图。图片显示了一个 TableViewController,其中第二部分的文本字段显示了键盘,我尝试了边界和滚动位置,但它不起作用。

有谁知道我怎么知道这个维度?

【问题讨论】:

    标签: ios swift uitableview keyboard height


    【解决方案1】:

    你可以通过改变 UITableView 底部的约束来做到这一点。

    将您的 UITableView 底部固定到 superView。然后注册 UIKeyboardWillShowNotification/UIKeyboardWillHideNotification 并从 NSNotification 对象键盘框架中获取并更改底部约束常量,如下所示:

    - (void)keyboardWillShow:(NSNotification *)notification {
        CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
        self.tableViewBottomConstraint.constant = CGRectGetHeight(keyboardRect);
       [self.view layoutIfNeeded];
    }
    

    【讨论】:

      猜你喜欢
      • 2011-04-17
      • 2017-09-19
      • 1970-01-01
      • 1970-01-01
      • 2015-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多