Created
September 22, 2014 09:39
-
-
Save jkyin/8cc9b10dedc05a070e0d to your computer and use it in GitHub Desktop.
Facebook SDK dismiss keyboard implemention
This file contains 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
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
// 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