Skip to content

Instantly share code, notes, and snippets.

@jkyin
Created September 22, 2014 09:39
Show Gist options
  • Save jkyin/8cc9b10dedc05a070e0d to your computer and use it in GitHub Desktop.
Save jkyin/8cc9b10dedc05a070e0d to your computer and use it in GitHub Desktop.
Facebook SDK dismiss keyboard implemention
///////////////////////////////////////////////////////////////////////////////////////////////////
// UIKeyboardNotifications
BOOL _showingKeyboard;
static CGFloat kPadding = 0;
static CGFloat kBorderWidth = 10;
static BOOL FBIsDeviceIPad() {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
}
#endif
return NO;
}
- (void)keyboardWillShow:(NSNotification *)notification {
_showingKeyboard = YES;
if (FBIsDeviceIPad()) {
// On the iPad the screen is large enough that we don't need to
// resize the dialog to accomodate the keyboard popping up
return;
}
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation)) {
_webView.frame = CGRectInset(_webView.frame,
- (kPadding + kBorderWidth),
- (kPadding + kBorderWidth));
}
}
- (void)keyboardWillHide:(NSNotification *)notification {
_showingKeyboard = NO;
if (FBIsDeviceIPad()) {
return;
}
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation)) {
_webView.frame = CGRectInset(_webView.frame,
kPadding + kBorderWidth,
kPadding + kBorderWidth);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment