ios 带十进制的数字键盘

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35437604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 08:32:08  来源:igfitidea点击:

Numeric keyboard with decimal

iosswiftuikeyboard

提问by Kevin

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

回答by tktsubota

Simply change the keyboard type:

只需更改键盘类型:

self.someTextField.keyboardType = UIKeyboardType.decimalPad

See the documentationfor all the keyboard types.

请参阅所有键盘类型的文档

回答by Naveen Kumar M

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

在属性检查器中为文本字段选择键盘类型中的十进制填充

Refer the image below for more detail

请参阅下面的图片了解更多详情

enter image description here

在此处输入图片说明

回答by Khushboo Dhote

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

在故事板中转到属性检查器。在那里您可以更改键盘类型。你可以在这里查看

回答by Deepak Tagadiya

set keyboard type to textField in swift 3

在swift 3中将键盘类型设置为textField

@IBOutlet weak var txtNumber: UITextField!  

override func viewDidLoad(){

    self.txtNumber.keyboardType = .decimalPad
}