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.
Related
Haven't found it on internet, searching on google I found Custom Keyboard as extension with is not what I need.
I need to make so that when you pressed my "Keyboard" on the bottom right (Its not actually a Keyboard, it is just a couple of UIButtons) the Inputs appear on the text field (Its the white space below ACTUAL CASH DEPOSIT).
So, when you press the text field, no keyboard should Appear, and When I start pressing the buttons of my "Custom Keyboard" the numbers should Appear.
I have found something similar in (Xcode 8 Swift 3). Using Custom Keyboard Extension with a particular Text Field But On my other Tap, Denominations I have multiple Input Fields. Like his image:
I know how to do all the code behind in terms of buttons pressed and calculations But I don't know how to make the input fields as a responder for my custom Keyboard.
You can't make it magically update - instead, I'd suggest binding all the buttons to a single function, and then then for instance use the tag property in IB to differentiate between them. Through that function update the text.
func didPressButton(button: UIButton) {
switch button.tag{
case 1: myTextField.text! += "1"
default: break
}
}
I'd caution you'll need to do some verification logic if you allow decimals so all numbers are valid.
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.
Right now when the keyboard launches on my application it defaults to the letter side showing an alphabetical keyboard.
Question will be listed below images
Refer to image below:
This is good. Clicking 123 will show the number side.
The Question:
However, I want to by default show the number side and still be able to switch back to the letter side later WHEN THE KEYBOARD IS OPEN. How do I do this?
Setting the keyboard programmatically to a different type is NOT the answer!
For example: User clicks in the text field, keyboard pops up and defaults to let's say the ABC side. The user can click 123 to switch. This is what I want. If the ability to switch while the keyboard is open is taken away it defeats the point of this question.
So if the Name Phone Pad keyboard defaults to the ABC side initially. I want it to default to the 123 side that way while the keyboard is still open it can switch to ABC again when the user clicks ABC.
I want to do this because I have different settings for how to search for barcodes. Either by name of the product or number based on settings the user set about how to index results. This way if they are sorting by number it suggests numbers first, BUT they can still go back to searching by alphabetical if they wanted by clicking the ABC button on the keyboard.
Here is the current setting for my keyboard.
keyboardType is property for a UITextField.
textField.keyboardType = UIKeyboardType.UIKeyboardTypeNumberPad
and
textField.keyboardType = UIKeyboardType.UIKeyboardTypeDefault
is how you can switch between the two modes programatically. Hope that helps.
To switch the Keyboardlayout programmatically you have to mutate UITextfield's keyboardType attribute.
Try
textField.keyboardType = UIKeyboardType.NumberPad;
or
textField.keyboardType = UIKeyboardType.PhonePad;
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.