当键盘以编程方式打开时,Swift自动布局会不断更改

当键盘以编程方式打开时,Swift自动布局会不断更改,swift,autolayout,Swift,Autolayout,我正在使用Autolayout,在这个页面上使用tableview和view with textfield。当键盘打开时,子视图和tableview常量应该改变。问题在于我的代码中只有子视图是向上滑动的,而tableview没有 func keyboardWillShow(notification: NSNotification?) { guard let keyboardFrame = (notification?.userInfo?[UIKeyboardFrameEndUs

我正在使用Autolayout,在这个页面上使用tableview和view with textfield。当键盘打开时,子视图和tableview常量应该改变。问题在于我的代码中只有子视图是向上滑动的,而tableview没有

func keyboardWillShow(notification: NSNotification?) {

        guard let keyboardFrame = (notification?.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue(),
            duration:NSTimeInterval = notification?.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? Double else {
            return
        }

        bottomConstraint.constant = keyboardFrame.size.height + 10
         BotTbl.constant = keyboardFrame.size.height + 10

        UIView.animateWithDuration(
            duration,
            animations: {
                self.view.layoutIfNeeded()
            },completion:nil)
    }

    func keyboardWillHide(notification: NSNotification?) {
        guard let duration = (notification?.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? Double) else {
            return
        }

        bottomConstraint.constant = 0
        BotTbl.constant = 10

        UIView.animateWithDuration(
            duration,
            animations:{
                self.view.layoutIfNeeded()
            },
            completion:nil)
    }