iPad没有像iPhone/iPod那样的"Numpad"键盘.
我想找到如何限制用户的键盘只接受值0到9.
我会想象使用UITextField的"shouldChangeCharactersInRange",但我不知道实现它的最佳方法.
我有一个数字可以说0.00.
0.010.121.2312.34我怎么能用Swift做到这一点?
在swift中,我试图创建一个允许按钮启用的文本字段,但仅当文本字段包含整数时.我怎样才能做到这一点?
我希望UITextfield的键盘只有az,没有数字,没有特殊字符(!@ $!@ $ @!#),没有大写字母.基本上我打算只用字母表键盘.
我已经能够禁用空间了.任何人都知道如何禁用数字,特殊字符和大写字母?任何这些解决方案都很棒.
对于所有角色来说,这是最好的解决方案,但我不想要?
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if (string == " ") {
return false
}
if (string == "1") {
return false
}
return true
}
Run Code Online (Sandbox Code Playgroud) 我想在进入UITextField时格式化(dd-MM-yyyy)文本,我使用swift 3.0,任何建议我如何实现相同的.
ios ×4
swift ×4
uitextfield ×3
swift3 ×2
cocoa-touch ×1
int ×1
ipad ×1
iphone ×1
objective-c ×1
text ×1
textfield ×1
uikeyboard ×1
xcode ×1