@objc func resizeSectionIndex(_ notification: Notification) {
let keyboardHeightInitial = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.height
let keyboardHeightFinal = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.height
print("Initial height: \(keyboardHeightInitial)")
print("Final height: \(keyboardHeightFinal)")
if notification.name == .UIKeyboardWillHide {
if keyboardHeightInitial != 0 && keyboardHeightInitial != keyboardHeightFinal {
let keyboardHeightDifference = keyboardHeightFinal! - keyboardHeightInitial!
tableView.frame.size.height = tableView.frame.size.height + keyboardHeightDifference
let myint = 233
return
}
tableView.frame.size.height = tableView.frame.size.height + keyboardHeightFinal!
}
if notification.name == .UIKeyboardWillShow {
if keyboardHeightInitial != keyboardHeightFinal {
let keyboardHeightDifference = keyboardHeightFinal! - keyboardHeightInitial!
tableView.frame.size.height = tableView.frame.size.height - keyboardHeightDifference
return
}
tableView.frame.size.height = tableView.frame.size.height - keyboardHeightFinal!
}
print(tableView.frame.size.height)
}
Comments