How to disable the emoji keyboard in iOS 7?

。_饼干妹妹 提交于 2019-12-21 12:51:36

问题


I wanted to disable the emoji keyboard programmatically. please let me know how can i do that ?

I tried using following code,

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"];
[dict setObject:[NSNumber numberWithBool:NO] forKey:@"KeyboardEmojiEverywhere"];

But no luck ... :(


回答1:


You can simply set the property keyboardType of the UITextField or UITextView to UIKeyboardTypeASCIICapable. This disables the Emoji Keyboard for this UI element.

This may not work in chinese how ever we have a workaround for it too :

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (IS_OS_7_OR_LATER) {
        if ([textField isFirstResponder]) {
            if ([[[textField textInputMode] primaryLanguage] isEqualToString:@"emoji"] || ![[textField textInputMode] primaryLanguage]) { // In fact, in iOS7, '[[textField textInputMode] primaryLanguage]' is nil
                return NO;
            }
        }
    } else {
        if ([[[UITextInputMode currentInputMode] primaryLanguage] isEqualToString:@"emoji"] ) {
            return NO;
        }
    }

    return YES;
}

User wont be able to type any emoji icon.




回答2:


Though The Question is super old, I was Facing the same problem and was able to resolve it by the time this page loaded by this small trick :

Simply Select Numbers and Punctuations in Interface Builder Xcode 8.2.1

Output is No Emoji Keyboard =D

I'm sure it'll help Someone =)




回答3:


The accepted answer works good, however currentInputMode is deprecated in iOS 7. Instead you could use textInputMode as stated in this SO thread:

+(BOOL)isEmojiInput:(UITextView)aTextView
{
    return [aTextView textInputMode] == nil;
}


来源:https://stackoverflow.com/questions/24927351/how-to-disable-the-emoji-keyboard-in-ios-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!