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.
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
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.
Related
I am trying to set an installed keyboard as the default input for a UITextField. Imagine you have a custom emoji keyboard called "AwesomeEmojis" and you want that keyboard to be the default keyboard programmatically . I have this code:
NSObject[] installedKeyboards = NSUserDefaults.StandardUserDefaults.ArrayForKey("AppleKeyboards");
I am able to see the list of keyboard in a NSMutableString format like:
"awesomeemoji#sw=AwesomeEmoji"
Is there any way that i can do something like:
AwesomeTextField.InputView = FromSystemKeyboards["awesomeemoji#sw=AwesomeEmoji"];
Please keep in mind the it's not a system keyboard. It's installed keyboard.
Thanks!
I'm making a custom keyboard so at first wanna make the one similar with real iOS keyboard.
On the iOS keyboard when I tap [123] button, the alphabet keys changes to number keys. THIS is what I want to do.
Is there any special ways for this?
self.textField.keyboardType = UIKeyboardType.NumberPad
Is there any way to programmatically detect installed keyboards and/or change the keyboard to a custom keyboard from within your app? As in, if I wanted to show a toolbar above the text keyboard with shortcut buttons to commonly-installed custom keyboards, could I a) detect the keyboard is installed, and b) change to a given keyboard on tap?
This assumes you want the list of keyboards setup in the Settings app under General, Keyboards.
You can determine the primary keyboard:
UITextInputMode *currentMode = [[UITextInputMode activeInputModes] firstObject];
You can determine the possible keyboards
NSArray *possibleModes = [UITextInputMode activeInputModes];
You can determine when the keyboard changes. This is done by listening for the UITextInputCurrentInputModeDidChangeNotification notification.
However, there is no API to change the keyboard.
So you can do everything you need except the most important part.
I've got a UITextView that needs to autocapitalize words. However, when I call any of these methods, the view does not respond.
[self.fullNameTextView setAutocapitalizationType:UITextAutocapitalizationTypeWords];
self.fullNameTextView.autocapitalizationType = UITextAutocapitalizationTypeWords;
Is this a bug in iOS 8.1?
I had the same issue and was able to solve it by settings my Keyboard type back to DEFAULT:
Please check your device Settings → General → Keyboard → Auto-Capitalization is turned on.
Both methods are valid of setting the property are valid. Are you testing using the simulator?
I found that autocapitalisation works only if you disable the hardware keyboard in Hardware > Keyboard > Connect Hardware Keyboard (Uncheck) and use the onscreen software keyboard. I tested this with iOS 8.1 with both UITextField and UITextView.
Edit
These properties determine the behaviour during manual input only. If you require the capitalisation of text that you are setting programmatically into the text view, use the following method:
NSString *myString = #"this is my uncapitalised string";
self.fullNameTextView.text = [myString capitalizedString]
self.fullNameTextView.autocapitalizationType = UITextAutocapitalizationTypeWords;
Note: It will not work if its simulator or Auto-Capitalisation is turned off from Settings>General>Keyboard>Auto-Capitalisation on iOS/iDevice. this solution doesn't work if auto correction is disabled for text view.
Just noticed that in UITextView keyboard comes without change language button, unlike in UITextField. Why Apple removed this button from UITextView keyboard? Is there any way to enable this button? I want people to be able to write notes on any keyboard language added in phone settings.
EDITED: Maybe it will help somebody in the future. Just noticed that I set keyboard type to UIKeyboardTypeAlphabet and this option eliminates language button. Closing this question.
P.S. I have 3 languages enabled in test iPhone.
You are completely wrong. there is no difference in UIKeyboard in iOS whatsoever. It only depends on what keyboard types you use.
UIKeyboardTypeDefault and UIKeyboardTypeEmailAddress and UIKeyboardTypeTwitter all have those.
You set it like this:
txtField.keyboardType = UIKeyboardTypeTwitter;
UIKeyboardTypeDefault is obviously the default one for any UITextView or UITextField in iOS.
For anyone have this problem even when using UIKeyboardTypeDefault on a UITextView, go into the storyboard and make sure "Secure Text Entry" is unchecked. After unchecking this, the keyboard selector will return as well as the quick type keyboard.