首页 > 其他 > 详细

判断键盘的高度

时间:2015-12-11 09:48:24      阅读:211      评论:0      收藏:0      [点我收藏+]

1、系统键盘跟第三方输入法都可以用这个方法

//    //增加监听,当键盘出现或改变时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    
    //增加监听,当键盘出现或改变时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];

 

- (void) keyboardWillShow:(NSNotification *)notif
{
    NSDictionary *info = [notif userInfo];
    NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
    keyBoardHeight = [value CGRectValue].size.height;
    
//    [UIView animateWithDuration:0.3f animations:^{
//        _appointCourseTV.contentOffset=CGPointMake(0, keyBoardHeight);
//    } completion:nil];
    
    
}
//回收键盘并落下输入框
- (void)keyboardWillHide:(NSNotification *)notif
{
    [_remarkTextView resignFirstResponder];
    [UIView animateWithDuration:0.3f animations:^{
        _appointCourseTV.contentOffset=CGPointMake(0, 0);
    } completion:nil];
    
//    [UIView animateWithDuration:0.3 animations:^{
//        
//        CGRect rect = CGRectMake(0, 0, M_S.width, M_S.height);
//        
//        self.view.frame = rect;
//        
//    }];
    
}

判断键盘的高度

原文:http://www.cnblogs.com/huoxingdeguoguo/p/5037935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!