键盘高度

来源:互联网 发布:华讯网络系统有限公司 编辑:程序博客网 时间:2024/05/17 09:12
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];  
    //UIKeyboardWillShowNotification键盘出现  
    [defaultCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];  
  
    //UIKeyboardWillHideNotification 键盘隐藏  
    [defaultCenter addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];  
  
- (void)keyboardWillShow:(NSNotification *)aNotification  
{  
    //获取键盘的高度  
    NSDictionary *userInfo = [aNotification userInfo];  
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];  
    CGRect keyboardRect = [aValue CGRectValue];  
    int height = keyboardRect.size.width;  
}  
0 0