Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set number side as default (while keyboard is open) of name phone pad keyboard type

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:

screenshot

This is good. Clicking 123 will show the number side.

screenshot

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.

screenshot

like image 761
Joseph Astrahan Avatar asked Apr 11 '16 08:04

Joseph Astrahan


1 Answers

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.

like image 57
Pankaj Avatar answered Oct 31 '22 08:10

Pankaj