UITextfield键盘只有字母,没有数字,没有大写字母,没有空格键? [英] UITextfield keyboard with only alphabet, no numbers, no caps, no spacebar?
本文介绍了UITextfield键盘只有字母,没有数字,没有大写字母,没有空格键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望UITextfield的键盘只有a-z,没有数字,没有特殊字符(!@ $!@ $ @!#),并且没有上限。基本上我只使用只有字母表的键盘。
I want the keyboard for the UITextfield to only have a-z, no numbers, no special characters (!@$!@$@!#), and no caps. Basicly I am going for a keyboard with only the alphabet.
我已经能够禁用该空间。任何人都知道如何禁用数字,特殊字符和大写字母?任何这些的解决方案都会很棒。
I was able to disable the space already. Anyone know how to disable numbers, special characters, and caps? A solution for any of these would be great.
对于所有角色都是最好的解决方案,但我不想要?
Is the best solution to do the below for all the characters but I dont want?
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if (string == " ") {
return false
}
if (string == "1") {
return false
}
return true
}
推荐答案
一种简单的方法是:
if let range = string.rangeOfCharacterFromSet(NSCharacterSet.letterCharacterSet())
return true
}
else {
return false
}
这篇关于UITextfield键盘只有字母,没有数字,没有大写字母,没有空格键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文