I put a textfield on a view and if I type the textfield a keyboard will be shown. I can click on the input change button on the keyboard to change input language to emoji. Now I want to let the keyboard shown with emoji input as the default one. How can I make it on ios with swift?
No this is not possible - user can only change their language in the settings.
The Emoji keyboard is effectively a language setting that the user has to make and we cannot influence that.
There is a keyboardType property for a UITextField:
typedef enum {
UIKeyboardTypeDefault, // Default type for the current input method.
UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
UIKeyboardTypeURL, // A type optimized for URL entry (shows . / .com prominently).
UIKeyboardTypeNumberPad, // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space # . prominently).
UIKeyboardTypeDecimalPad, // A number pad including a decimal point
UIKeyboardTypeTwitter, // Optimized for entering Twitter messages (shows # and #)
UIKeyboardTypeWebSearch, // Optimized for URL and search term entry (shows space and .)
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
} UIKeyboardType;
Related
I Created a keyboard extension like this:
But I don't know where to define my custom keyboard to be a numeric pad.
If any number type textfield tapped by user, the iOS default numeric pad will present with no switch button to my custom numeric pad.
The question is:
How to define my custom keyboard to be a numeric pad?
From Apple's docs Custom Keyboard:
Your custom keyboard is also ineligible to type into so-called phone pad objects, such as the phone number fields in Contacts. These input objects are exclusively for strings built from a small set of alphanumeric characters specified by telecommunications carriers and are identified by having one or another of the following two keyboard type traits:
UIKeyboardTypePhonePad
UIKeyboardTypeNamePhonePad
When a user taps in a phone pad object, the system temporarily replaces your keyboard with the appropriate, standard system keyboard. When the user then taps in a different input object that requests a standard keyboard via its type trait, your keyboard automatically resumes.
So, it looks like you cannot do what you're asking.
Right now when using textField.keyboardType = .namePhonePad, it will automatically start out showing the alpha keyboard, and you then have to press the number toggle to see the number pad. Is there any way to reverse that and have the number pad show first as the default and then be able to manually toggle to the alpha keyboard?
I know it's possible to create a custom button to be able to toggle the keyboard type, as well as changing the keyboard type based on what they type into the text field, but I just want a way to change its default first keyboard.
Or maybe add a comma on the number pad without creating a custom keyboard.
I tried changing NSLocale to to another country but that didn't work. I have a function that separates multiple numbers from textFiled to evaluate them separately separated by commas but the keyboards do not contain a comma and i would rather not use the numbers and punctuation keyboard for this. Any help is appreciated. Using Xcode 7.2.
You can't change the keys on any of the built-in keyboards.
You can create your own keyboard view with the inputs you want (numbers, the comma, backspace) and set it as the inputView of your text field. The system will display your keyboard view instead of a standard keyboard when your text field becomes first responder.
Or you can just create, say, a toolbar with a comma button on it, and set the toolbar as your text field's inputAccessoryView, and let the text field use the standard decimal pad for numbers and backspace. The system will display your input accessory view above the standard keyboard when your text field becomes first responder.
Read “Input Views and Input Accessory Views” in the Text Programming Guide for iOS.
I've build a custom keyboard, but I don't want that the people to go to Settings > General. Select Keyboard and then click on Add Keyboard, I would like the people just open the app and when a certain text field get focused my custom keyboard appear.
How can I achieve this?
You can not do it. User must have to select keyboard from the settings. You can not force to use your keyboard by the user.
For more check the documents provided by apple for the custom keyboard : https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html
There are some pros and cons also there.
You can not force the user to choose your keyboard.
If it really matter, you may add a custom view as input for your textfield, and implement your keyboard in that view.
Good luck.
Simply you can not force user to use your custom keyboard. If user select your custom keyboard form setting then they can use your custom keyboard but without selecting your custom keyboard from setting they can not use your custom keyboard.
If your textField need some special type of input then you can set keyboard for it by selecting your textField go to Attribute inspector at keyBoard type you can find some default Keyboard which is available by apple as shown in below Image:
You can use any of this keyboard from here.
And If you want to set it Programmatically you can do it this way:
yourTextField.keyboardType = .NumberPad
Here is a keyboardType property for a UITextField:
enum UIKeyboardType : Int {
case Default // Default type for the current input method.
case ASCIICapable // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
case NumbersAndPunctuation // Numbers and assorted punctuation.
case URL // A type optimized for URL entry (shows . / .com prominently).
case NumberPad // A number pad (0-9). Suitable for PIN entry.
case PhonePad // A phone pad (1-9, *, 0, #, with letters under the numbers).
case NamePhonePad // A type optimized for entering a person's name or phone number.
case EmailAddress // A type optimized for multiple email address entry (shows space # . prominently).
#availability(iOS, introduced=4.1)
case DecimalPad // A number pad with a decimal point.
#availability(iOS, introduced=5.0)
case Twitter // A type optimized for twitter text entry (easy access to # #)
#availability(iOS, introduced=7.0)
case WebSearch // A default keyboard type with URL-oriented addition (shows space . prominently).
}
Hope it will help you.
I have some alphanumeric content that gets entered routinely and is mostly numbers, so I'm wondering if there's a way to start in the numeric side of the keyboard but still have the option to switch to the alphabetic keyboard in Objective-C for iPhone development specifically. I've found plenty of info on using the numeric keyboard but I'd like to start there but still be able to enter letters if that's possible.
Thanks.
Set the keyboardType property to UIKeyboardTypeNumbersAndPunctuation.
This will default the iPhone's keyboard to show numbers and punctuation but the little "ABC" key will be in the bottom left allowing the user to switch back to the letters (and then back to numbers and punctuation).
Try this:
[Objective - C]
[self.myTextField setKeyboardType: UIKeyboardTypeNumbersAndPunctuation];
[Swift]
self.myTextField.keyboardType = .NumbersAndPunctuation
// You can also set this property from the storyboard.