如何在iOS 7中禁用表情键盘?
我想通过编程禁用表情键盘。请告诉我怎么做 我试着使用下面的代码如何在iOS 7中禁用表情键盘?,ios,emoji,Ios,Emoji,我想通过编程禁用表情键盘。请告诉我怎么做 我试着使用下面的代码 NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"]; [dict setObject:[NSNumber numberWithBool:NO] forKey:@"KeyboardEmoji
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"];
[dict setObject:[NSNumber numberWithBool:NO] forKey:@"KeyboardEmojiEverywhere"];
但是没有运气…:(您只需将UITextField或UITextView的属性keyboardType设置为UIKeyboardTypesCicable。这将禁用此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;
}
用户将无法键入任何表情符号图标。接受的答案效果良好,但在iOS 7中不推荐使用currentInputMode。相反,您可以使用textInputMode,如中所述:
虽然这个问题非常古老, 我也遇到了同样的问题,当这个小技巧加载到这个页面时,我已经解决了这个问题: 只需在Interface Builder Xcode 8.2.1中选择数字和标点符号 输出为无表情键盘=D
我确信它会帮助某人=)如果我们使用UIKeyboardTypesCapable,多语言支持是不可能的:(。我想支持多语言,但表情符号应该被禁用。currentInputMode在ios 7中被取消。
+(BOOL)isEmojiInput:(UITextView)aTextView
{
return [aTextView textInputMode] == nil;
}