开发者

iPhone UITextField Keyboard Space Switching Layout

开发者 https://www.devze.com 2022-12-20 03:39 出处:网络
I want the user to be able to type in only numbers and spaces. I set the keyboardType te开发者_运维技巧xtField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; but if a user hits space, the keyboar

I want the user to be able to type in only numbers and spaces. I set the keyboardType te开发者_运维技巧xtField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; but if a user hits space, the keyboard layout switches to letters.

So the user has to switch after each space to the number layout which I want to stop. I know I can stop entering any spaces by the textfield delegate method shouldChangeCharactersInRange or or the NumberPad Layout but I want the spaces to display.

Is there a workaround for this?


Potentially you could use the keyboard layout suggested here but instead of a "Done" button you could include a "_" spacebar button? This has the added benefit of preventing the user from selecting any punctuation.

An alternate answer to specifically the behavior you're seeing is found in this other post.

0

精彩评论

暂无评论...
验证码 换一张
取 消