I'm having a problem, and I was wandering if somebody already experienced this before.
The setup I have is the following:
- I use a UIViewController with which is made up of 3 elements
- UIView at the top
- UITableView in the centre
- UiView at the bottom
What I'm doing is the following: I'm animating the bottom UIView to be push up once the keyboard is showed. This works fine, but the problem I'm having is that once the keyboard disappears, the section header of the fist cell in the table view is moved a bit downloads with the movement of the animation.
extension UserDetailsViewController: KeyboardDelegate {
func keyboardWillShow(notification: NSNotification) {
if let info = notification.userInfo {
let keyboardFrame = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
UIView.animate(withDuration: 0.3, animations: {
if UserDeviceType.IPad || UserDeviceType.IPadPro {
self.updateConstraints(gradientHeight: 90, footerHeight: 60, footerBottom: keyboardFrame.height)
} else if UserDeviceType.IPhone5 || UserDeviceType.IPhone4 {
self.updateConstraints(gradientHeight: 65, footerHeight: 40, footerBottom: keyboardFrame.height)
} else if UserDeviceType.IPhoneX {
self.updateConstraints(gradientHeight: 90, footerHeight: 60, footerBottom: keyboardFrame.height)
} else {
self.updateConstraints(gradientHeight: 67, footerHeight: 40, footerBottom: keyboardFrame.height)
}
self.view.layoutIfNeeded()
self.tableView.layoutIfNeeded()
})
}
}
func keyboardWillHide(notification: NSNotification) {
UIView.animate(withDuration: 0.3, animations: {
self.setupConstraints()
self.view.layoutIfNeeded()
self.tableView.layoutIfNeeded()
})
}
}