码迷,mamicode.com
首页 > 其他好文 > 详细

判断键盘的高度

时间:2015-12-11 09:49:08      阅读:156      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!