开发者

How to limit iOS keyboard to numeric input

开发者 https://www.devze.com 2023-04-04 21:29 出处:网络
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 UIKeyboardTypeDecima

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

精彩评论

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