How can I show the numeric keyboard by default on iPhone?

安稳与你 提交于 2019-11-30 04:39:13
Jacob Relkin

The UITextInputTraits protocol (which UITextField conforms to) has a keyboardType property of type UIKeyboardType.

myTextField.keyboardType = UIKeyboardTypeNumberPad;
Luda

This could be done in the Interface Builder as well:

UITextField conforms to UITextInputTraits protocol which means it has keyboardType property which you can set.

myField.keyboardType = UIKeyboardTypeNumberPad;

You can also set it via interface builder. From the text input traits set the keyboard to number pad and that's all.

We can get it by interface approach also.Select the text field and go to attribute inspector and change the keyboard type from the keyboard drop down box.

If you want to show a numerical keyboard but also need to be able to use decimal points, currency symbols, or other characters, you can have the keyboard default to the back side of the alphabet keyboard.

currentTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!