问题
I have a textfield where i need the user to select an emoji to proceed. How do i trigger the emoji keyboard by default?
I know there is a way to get all keyboards but i am not sure how to select one by default.
NSArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleKeyboards"];
NSLog(@"Keyboards: %@", array);
The output of all the installed international keyboards looks as follows:
Keyboards: (
"en_US@hw=US;sw=QWERTY",
"zh_Hant-HWR@sw=HWR",
"emoji@sw=Emoji"
)
I am supporting only iOS 9.0, so i am ok with assuming the user has an emoji keyboard.
回答1:
it seems that you cannot do this, iOS does not provide any public api to programatically switch to another input method, and emoji keyboard is regarded as a kind of input method.
回答2:
It can be done by sub-classing UITextField and return the proper mode value for textInputMode
.
See this answer: change the keyboard layout to emoji
来源:https://stackoverflow.com/questions/36541966/show-emoji-keyboard-programatically-in-ios-9-0