How do I find out the current keyboard used on iOS8?

后端 未结 4 2104
暖寄归人
暖寄归人 2020-12-14 02:52

You can get a list of the keyboards installed on the iOS device using:

NSUserDefaults *userDeafaults = [NSUserDefaults standardUserDefaults];
NSDictionary *          


        
4条回答
  •  失恋的感觉
    2020-12-14 03:38

    Leo Natan's answer is great, but I would like to add something to it. You can actually get the current input mode at any time, not just when the keyboard is open, like this:

    UITextView *textView = [[UITextView alloc] init];
    UITextInputMode *inputMode = textView.textInputMode;
    

    Please note that textView.textInputMode is nil for the Emoji keyboard for some reason.

    Also, in addition to displayName and extendedDisplayName, there are other keys you can retrieve, such as identifier, normalizedIdentifier (iOS 8+), hardwareLayout, ... See the full API here:

    https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UIKeyboardInputMode.h

    Now I'm not sure if using any of those is more risky than displayName for App Store approval...

提交回复
热议问题