监听系统键盘的方法

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(KeyBoardWillChange:) name:UIKeyboardWillChangeFrameNotification object:nil];

//监听通知的方法

-(void)KeyBoardWillChange:(NSNotification *)notification{

    CGFloat height = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].origin.y;

    [UIView animateWithDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue] animations:^{

//自定义输入框 _inputView

        _inputView.frame=CGRectMake(0, height-49, SCREEN_WIDTH, 49);

        

    }];

}

posted @ 2015-03-11 21:41  易林夕  阅读(219)  评论(0)    收藏  举报