第三方键盘与原生键盘通用遮挡处理方法

-(void)EBAddKEyBoardNotic
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
}

-(void)EBRemoveKeyBoardNotic
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
}
- (void)keyboardWillChangeFrame:(NSNotification *)notification

{
    NSDictionary *userInfo = notification.userInfo;
    [UIView animateWithDuration:[[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue] animations:^{
        NSDictionary* d = [notification userInfo];
        
        CGRect r = [d[UIKeyboardFrameEndUserInfoKey] CGRectValue];
        CGRect frame = self.view.frame;
        frame.origin.y = CGRectGetMinY(r) - (CGRectGetHeight(frame) + 20 + 44 + 35);//状态栏 导航栏 + wmpage标签高度
        self.view.frame = frame;
    }];
}

 

posted @ 2016-05-04 13:13  niwanglong385  阅读(150)  评论(0)    收藏  举报