Numeric keyboard with decimal

江枫思渺然 提交于 2019-12-05 09:28:58

问题


I´m building an app with equations and I have used a numeric keyboard but I want to have a decimal slot on it. The default is only numbers. How do you add a decimal input on that keyboard?

This is the code I use to get the numeric keyboard

.keyboardType = UIKeyboardType.NumberPad

回答1:


Simply change the keyboard type:

self.someTextField.keyboardType = UIKeyboardType.decimalPad

See the documentation for all the keyboard types.




回答2:


Select Decimal Pad in Keyboard Type for Text Field in Attribute Inspector.

Refer the image below for more detail




回答3:


In storyboard go to Attribute Inspector. There you can change keyboard type.You can check here




回答4:


set keyboard type to textField in swift 3

@IBOutlet weak var txtNumber: UITextField!  

override func viewDidLoad(){

    self.txtNumber.keyboardType = .decimalPad
}


来源:https://stackoverflow.com/questions/35437604/numeric-keyboard-with-decimal

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