Last active
October 2, 2015 14:46
-
-
Save fabiomassimo/c86a4740adf188b0473b to your computer and use it in GitHub Desktop.
[iOS 9] - Retrieve visible keyboard frame on `keyboardWillChange` event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)keyboardWillChange:(NSNotification *)notification | |
{ | |
CGRect keyboardFrame = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; | |
CGFloat finalHeight = CGRectGetHeight([self.view frame]) - CGRectGetMinY(keyboardFrame) ; | |
keyboardFrame.size.height = finalHeight; | |
NSLog(@"The visible keyboard frame is %@", NSStringFromCGRect(keyboardFrame)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found this useful when an external keyboard is connected and the utility bar is still visible on the screen.