大佬教程收集整理的这篇文章主要介绍了如何找出iOS8上使用的当前键盘?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
NSUserDefaults *userDeafaults = [NSUserDefaults standardUserDefaults]; NSDictionary * userDefaultsDict = [userDeafaults DictionaryRepresentation]; NSLog(@"%@",userDefaultsDict);
这在控制台中产生一些东西,如:
{ ... AppleKeyboards = ( "en_US@hw=US;sw=QWERTY","es_ES@hw=Spanish - ISO;sw=QWERTY-Spanish","emoji@sw=Emoji","com.swiftkey.SwiftKeyApp.Keyboard" ); AppleKeyboardsExpanded = 1; ... }
这告诉我,该设备安装了西班牙语,表情符号和SwiftKey键盘,但是当键盘出现时,它将告诉我什么都不会使用.
有没有办法告诉?
iOS有以下类:UITextInputMode
这个类给你所有用户可以使用的输入方法.使用以下查询将会给您当前使用的,只有当键盘打开时:
UITexTinputMode* inputMode = [[[UITexTinputMode activeInputModes] filteredArrayUsingPreDicate:[NSPreDicate preDicateWithFormat:@"isDisplayed = YES"]] lastObject];
[inputMode valueForKey:@"displayName"]
要么
[inputMode valueForKey:@"extendedDisplayName"]
这只有当键盘可见时才有效.所以你必须自己监视输入模式的改变
[[NsnotificationCenter defaultCenter] addObserverForName:UITexTinputCurrenTinputModeDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(Nsnotification *notE) { dispatch_async(dispatch_get_main_queue(),^{ NSLog(@"%@",[[[[UITexTinputMode activeInputModes] filteredArrayUsingPreDicate:[NSPreDicate preDicateWithFormat:@"isDisplayed = YES"]] lastObject] valueForKey:@"extendedDisplayName"]); }); }];
我们实际上需要延迟获取当前的输入模式,因为通知是在键盘内部实现使用新值更新系统之前发送的.在下一个循环中获取它的效果很好.
以上是大佬教程为你收集整理的如何找出iOS8上使用的当前键盘?全部内容,希望文章能够帮你解决如何找出iOS8上使用的当前键盘?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。