[英]How to disable the emoji keyboard in iOS 7?
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 ... :( 但没有运气...... :(
You can simply set the property keyboardType of the UITextField or UITextView to UIKeyboardTypeASCIICapable. 您只需将UITextField或UITextView的属性keyboardType设置为UIKeyboardTypeASCIICapable即可。 This disables the Emoji Keyboard for this UI element.
这会禁用此UI元素的表情符号键盘。
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. 用户将无法键入任何表情符号图标。
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
只需在Interface Builder Xcode 8.2.1中选择数字和标点符号
Output is No Emoji Keyboard =D 输出为无表情符号键盘= D.
I'm sure it'll help Someone =) 我相信它会帮助某人=)
The accepted answer works good, however currentInputMode is deprecated in iOS 7. Instead you could use textInputMode as stated in this SO thread : 接受的答案很有效,但iOS 7中不推荐使用currentInputMode。相反,您可以使用此SO线程中所述的textInputMode:
+(BOOL)isEmojiInput:(UITextView)aTextView
{
return [aTextView textInputMode] == nil;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.