UIKeyBoard高度的监控

来源:互联网 发布:securecrt 8.1.4 mac 编辑:程序博客网 时间:2024/06/05 00:26

监控KeyBoard


    [[NSNotificationCenter defaultCenteraddObserver:self selector:@selector(keyBoardWillShow:)name:UIKeyboardWillShowNotification object:nil];

    [[NSNotificationCenter defaultCenteraddObserver:self selector:@selector(keyBoardWillHidden:)name:UIKeyboardWillHideNotification object:nil];


显示的实现

- (void) keyBoardWillShow:(NSNotification*) notification

{

    

    NSDictionary *userInfo = [notification userInfo];

    

    // Get the origin of the keyboard when it's displayed.

    NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

    

    // Get the top of the keyboard as the y coordinate of its origin in self's view's coordinate system. The bottom of the text view's frame should align with the top of the keyboard's final position.

    CGRect keyboardEndFrame = [aValue CGRectValue];

    CGRect keyboardFrame = [self.view convertRect:keyboardEndFrame toView:nil];


    CGFloat keyboardHeight = keyboardFrame.size.height;    

}

0 0
原创粉丝点击