Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable or hide localization in Number keyboard type?

In my iOS app, when the user click on a UITextfield I need to change the keyboard view to the numeric view automatically. I write below code and it is working fine.

UITextField *txtfield  = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
txtfield.keyboardType = UIKeyboardTypeNumberPad;

My app supports localization. I added 4 keyboards on the device like English, Spanish, Hindi, Emoji. I want disable or hide localization in number keyboard type. Please see attached image. I have highlighted in red box.

enter image description here

Anyone knows how to do that?

like image 996
Kirti Nikam Avatar asked Apr 19 '17 10:04

Kirti Nikam


People also ask

How to disable Insert key in Windows 10?

If the Overtype mode is enabled, you need to press the Insert key to disable Overtype. If you just want to undo Insert key but keep the functions of the Insert key, you are down. However, if you want to disable Insert permanently, you can continue the following steps. 2. Press Win + R to open Run.

How can I hide the on-screen keyboard?

how can I hide the on-screen keyboard. I never use it and have to close it every time I open the computer. Open Control Panel / Ease of Access Center. Select the Use the computer without a mouse or keyboard option. Remove the check mark from the Use onscreen keyboard option.

Why is there no numeric keypad on my laptop keyboard?

Due to their compact size, many laptops don’t include a dedicated numeric keypad on the right side of the keyboard like a desktop computer. To conserve space, the keys of numeric keypad are shared keys with a block of keys in the center of the keyboard.

How do I disable the NumLock key at startup?

If you want the NumLock key enabled for use before a user presses CTRL+ALT+DEL to log on, you must use Registry Editor to change the default behavior. Here is a simple registry fix to disable the NumLock key at startup: Press Windows + R to bring up the Run box. Type regedit and press Enter to open the Windows Registry Editor.


Video Answer


2 Answers

(Applies for iOS 10 or later)

Swift

Use .asciiCapableNumberPad for Xcode 8.3/Swift 3.1 for only numbers

txtField.keyboardType = .asciiCapableNumberPad

Objective-C

txtField.keyboardType = UIKeyboardTypeASCIICapableNumberPad
like image 81
Jack Avatar answered Sep 23 '22 04:09

Jack


@Jack answer is correct but if you need to support iDevices with iOS9 and below, you need to put a check like this:

if (IS_OS_10_OR_LATER) {
  txtfield.keyboardType = UIKeyboardTypeASCIICapableNumberPad;
}
else {
  txtfield.keyboardType = UIKeyboardTypeNumberPad;
}

If not, the users will see a Default keyboard type if their iDevice is still on iOS9 and below.

like image 22
aNa12 Avatar answered Sep 19 '22 04:09

aNa12