iOS中弹出键盘高度

#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);

}

posted @ 2015-11-12 09:54  iOS_Country  阅读(350)  评论(0编辑  收藏  举报