swift - UITableView Cell 显示问题

标签 swift uitableview ios-autolayout

screenShot when keyboard is appear Image wheh keyboard is not present Image of the storyboar :

我有一个UITableView,它的顶部和底部到 super View 的距离是0。 当键盘出现时,我更新底部约束,以便键盘不会隐藏表格。但是在更新底部约束时,最后两个或三个单元格并不完全可见。我正在使用以下代码来更新底部约束。

func keyboardWillChangeFrameWithNotification(notification: NSNotification, showsKeyboard: Bool) {
let userInfo = notification.userInfo!
    let animationDuration: NSTimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue

    // Convert the keyboard frame from screen to view coordinates.
    let keyboardScreenBeginFrame = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).CGRectValue()

    if showsKeyboard
    {
       cntInputViewBottom.constant = keyboardScreenBeginFrame.size.height

    }
    else
    {
         cntInputViewBottom.constant = 0
    }
}

最佳答案

您正在使用UIKeyboardFrameBeginUserInfoKey。这是帧更改动画开始时键盘的大小。您最好使用 UIKeyboardFrameEndUserInfoKey 以获得最终帧。

关于swift - UITableView Cell 显示问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36147759/

相关文章:

带有标题区域的 iPhone UITableView

swift - UIImageView 在 StackView 和 TableViewCell 中不是自动高度

ios - 如何使用 Storyboard 设置包装文本 UILabel Xcode

ios - UITableview 只滚动到中间 - Swift 4

swift - 为什么是我的代表?即使我的选择器一如既往地查看数据,也发现为零?

swift - 直接赋值UnsafePointer

json - Swift - 无法使用泛型转换类型的值

objective-c - 以编程方式选择 uitableview 行

ios - UIView 以编程方式设置约束

ios - 如何生成数字和字母混合的随机代码 - Swift