我正在使用Autolayout,在此页面上查看tableview并使用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)
}