如何在iOS 7中禁用表情符号键盘? [英] How to disable the emoji keyboard in iOS 7?

查看:117
本文介绍了如何在iOS 7中禁用表情符号键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式禁用表情符号键盘。请告诉我该怎么做?

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

我尝试使用以下代码,

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

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

But no luck ... :(

推荐答案

您可以简单地将UITextField或UITextView的属性keyboardType设置为UIKeyboardTypeASCIICapable。这会禁用此UI元素的表情符号键盘。

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.

这篇关于如何在iOS 7中禁用表情符号键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆