#pragma mark - 监听键盘的通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; //键盘弹出时的通知
#pragma mark - keyboardWillShow的通知,获取键盘的高度
- (void)keyboardWillShow:(NSNotification *)aNotification {
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
NSLog(@“键盘高度 = %f", keyboardRect.size.height);
}