iOS检测键盘输入语言类型

来源:互联网 发布:mac管理员用户名修改 编辑:程序博客网 时间:2024/06/11 13:13
- (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];}

0 0
原创粉丝点击