Created
September 8, 2011 23:31
-
-
Save mikeyk/1205091 to your computer and use it in GitHub Desktop.
Get keyboard height from an NSNotification
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
@implementation NSNotification (KeyboardHeight) | |
- (CGFloat)keyboardHeight { | |
CGRect bounds; | |
NSValue *boundsValue = [self.userInfo objectForKey:UIKeyboardBoundsUserInfoKey]; | |
if (boundsValue) { | |
[boundsValue getValue:&bounds]; | |
return bounds.size.height; | |
} else { | |
return 0; | |
} | |
} | |
@end |
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
@implementation NSNotification (KeyboardHeight) | |
- (CGFloat)keyboardHeight { | |
CGRect bounds; | |
NSValue *boundsValue = [self.userInfo objectForKey:UIKeyboardBoundsUserInfoKey]; | |
if (boundsValue) { | |
[boundsValue getValue:&bounds]; | |
return bounds.size.height; | |
} else { | |
return 0; | |
} | |
} | |
@end |
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
@implementation NSNotification (KeyboardHeight) | |
- (CGFloat)keyboardHeight { | |
CGRect startFrame; | |
NSValue *startFrameValue = [self.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey]; | |
if (startFrameValue) { | |
[startFrameValue getValue:&startFrame]; | |
return startFrame.size.height; | |
} else { | |
return 0; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment