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

监听键盘通知

时间:2015-12-28 09:07:06      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:

//监听键盘状态 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; 
    //监听输入法状态 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeInputMode:) name:UITextInputCurrentInputModeDidChangeNotification object:nil]; 

 
#pragma mark Notification 
//keyBoard已经展示出来 
- (void)keyboardDidShow:(NSNotification *)notification 

    NSValue* aValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]; 
    CGRect keyboardRect = [aValue CGRectValue]; 
    CGRect keyboardFrame = [self.view convertRect:keyboardRect fromView:[[UIapplication sharedApplication] keyWindow]]; 
    CGFloat keyboardHeight = keyboardFrame.size.height; 
    NSLog(@"##keboardHeight=%.2f",keyboardHeight); 

 
//输入法发生切换 
-(void)changeInputMode:(NSNotification *)notification{ 
    NSString *inputMethod = [[UITextInputMode currentInputMode] primaryLanguage]; 
    NSLog(@"inputMethod=%@",inputMethod); 

监听键盘通知

标签:

原文地址:http://www.cnblogs.com/zs12/p/5081474.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!