【问题标题】:Adjust UITableView to allow for keyboard调整 UITableView 以允许使用键盘
【发布时间】:2019-06-02 22:36:02
【问题描述】:

当键盘显示在所有设备的屏幕上时,调整UITableView 高度的神奇咒语是什么?在keyboardDidShow通知中,我在做

tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardSize.height - view.safeAreaInsets.bottom, right: 0)
tableView.scrollIndicatorInsets = tableView.contentInset

我的表格视图的底部约束是Align Bottom to: Safe Area

这适用于所有 iPhone 5|6|7|8 类型的设备,但不适用于 iPhone X* 设备;调整量不够,无法将桌面底部向上移动到键盘顶部。大约 58 像素短。

当然,必须有某种方法可以使其普遍适用,是吗?我错过了什么?

【问题讨论】:

    标签: ios uitableview autolayout uikeyboard


    【解决方案1】:

    这是因为 iPhone X 以外的 iPhone 没有底部安全区。 尝试删除 view.safeAreaInsets.bottom。

    【讨论】:

      猜你喜欢
      • 2012-11-30
      • 1970-01-01
      • 2018-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-09
      • 2020-11-19
      • 1970-01-01
      相关资源
      最近更新 更多