标签:
//监听键盘状态
[[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