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

后端 未结 4 2107
暖寄归人
暖寄归人 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:16

    @Leo Natan's answers is cool but it's may return nil when the keyboard have not display.

    So here I use the string to find the UIKeyboardInputMode's property.

    I can tell you that this can find out the current keyboard because it's comes from Apple's Private API.

    Code here:

    + (BOOL)isTheCustomKeyboard
    {
        UITextInputMode* inputMode = [UITextInputMode currentInputMode];
        if ([inputMode respondsToSelector:NSSelectorFromString(@"identifier")])
        {
            NSString* indentifier = [inputMode performSelector:NSSelectorFromString(@"identifier")];
            if ([indentifier isEqualToString: YOUR_APP_ID])
            {
                return YES;
            }
        }
       return NO;
    }
    

    And more:

    + (BOOL)isContaintCustomKeyboard
    {
        NSArray * inputModes = [UITextInputMode activeInputModes];
        for (id inputModel in inputModes)
        {
            if ([inputModel respondsToSelector:NSSelectorFromString(@"identifier")])
            {
                NSString* indentifier = [inputModel performSelector:NSSelectorFromString(@"identifier")];
                if ([indentifier isEqualToString: YOUR_APP_ID])
                {
                    return YES;
                }
            }
        }
        return NO;
    }
    

    Actually we can also use the displayName or the identifier and more.

提交回复
热议问题