- (void)viewDidLoad
{
[super viewDidLoad];
NSNotificationCenter *nCenter = [NSNotificationCenter defaultCenter];
[nCenter addObserver:self selector:@selector(languageChanged:) name:UITextInputCurrentInputModeDidChangeNotification object:nil];
// [self languageChanged:nil];
}
- (void)languageChanged:(NSNotification*)notification
{
NSLog(@"Current: %@", [UIApplication sharedApplication].delegate.window.textInputMode.primaryLanguage);
// for(UITextInputMode *mode in [UITextInputMode activeInputModes])
// {
// NSLog(@"Input mode: %@", mode);
// NSLog(@"Input language: %@", mode.primaryLanguage);
// }
// NSLog(@"Notification: %@", notification);
// UITextInputMode *current = [UITextInputMode currentInputMode];
// NSLog(@"Current: %@", current.primaryLanguage);
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
iOS检测键盘输入语言类型
最新推荐文章于 2021-01-17 13:32:21 发布