UIKeyboardFrameEndUserInfoKey height incorrect (should be 48pt less)
I found the answer.
I'm pretty sure you have a tab bar. The tab bar height is 49 points.
When your constant value is 0 (keyboard hidden), your view is still 49 points above 0.
So you have 2 options: 1. Keep subtracting 49 points. 2. Present the view controller instead of pushing to get rid of the tab bar.
For anyone still stumbling on this: I think the safest answer is buried in the comments of @Oded's answer:
You should get the height of the UITabBar
then subtract it from the keyboard height:
Objective-C::
[[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height-self.tabBarController.tabBar.frame.size.height
Swift:
let tabBarHeight = tabBarController?.tabBar.frame.height ?? 0
let keyboardFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? 0.0
let adjustedKeyboardHeight = keyboardFrame.height - tabBarHeight