如何在iOS 7中禁用表情符号键盘?

Bha*_*hat 6 ios emoji

我想以编程方式禁用表情符号键盘.请让我知道我该怎么做?

我尝试使用以下代码,

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"];
[dict setObject:[NSNumber numberWithBool:NO] forKey:@"KeyboardEmojiEverywhere"];
Run Code Online (Sandbox Code Playgroud)

但没有运气...... :(

Xei*_*han 7

您只需将UITextField或UITextView的属性keyboardType设置为UIKeyboardTypeASCIICapable即可.这会禁用此UI元素的表情符号键盘.

这可能不适用于中文我们如何解决它:

- (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;
}
Run Code Online (Sandbox Code Playgroud)

用户将无法键入任何表情符号图标.