如何禁用iOS 7中的表情符号键盘?
我想以编程方式禁用表情符号键盘。 请让我知道我该怎么做?
我试过使用下面的代码,
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"]; [dict setObject:[NSNumber numberWithBool:NO] forKey:@"KeyboardEmojiEverywhere"];
但没有运气… 🙁
您可以简单地将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; }
用户将无法input任何表情符号图标。
接受的答案效果很好,但是在iOS 7中不推荐使用currentInputMode。相反,您可以使用此SO线程中所述的textInputMode:
+(BOOL)isEmojiInput:(UITextView)aTextView { return [aTextView textInputMode] == nil; }
虽然这个问题是超级老,我面对同样的问题,并能够解决这个页面加载这个小窍门:
只需在Interface Builder Xcode 8.2.1中selectNumbers和Punctuations
输出是否表情符号键盘= D
我确定它会帮助某人=)