开发者

How to limit iOS keyboard to numeric input

The question 开发者_高级运维pretty much says it all. Is there any way to have the iOS/iPhone keyboard default to numeric input?


Set the keyboardType property of the UITextField to UIKeyboardTypeDecimalPad.

Swift 3

yourUITextField.keyboardType = .decimalPad


Objective-C:

Default to Numbers (but include - and . if you need to allow decimal or negative numbers):

myTextField1.keyboardType=UIKeyboardTypeNumbersAndPunctuation;

Default to Numbers (#s only for integer values)

myTextField1.keyboardType=UIKeyboardTypeNumberPad;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜