Show Emoji keyboard programatically in iOS 9.0

折月煮酒 提交于 2020-06-02 04:13:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!