Skip to content

Instantly share code, notes, and snippets.

@fabiomassimo
Last active October 2, 2015 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiomassimo/c86a4740adf188b0473b to your computer and use it in GitHub Desktop.
Save fabiomassimo/c86a4740adf188b0473b to your computer and use it in GitHub Desktop.
[iOS 9] - Retrieve visible keyboard frame on `keyboardWillChange` event
- (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));
}
@fabiomassimo
Copy link
Author

I found this useful when an external keyboard is connected and the utility bar is still visible on the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment