总是(强制)输入小写或大写字母-iOS Swift

如何以快速语言强制某些文本字段键入小写或大写?

回答:

您应该return false进入,if block因为您已经更新了textfield

func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {

if textField.isEqual(textFieldBodrum) {

textFieldBodrum.text = (textField.text as NSString).stringByReplacingCharactersInRange(range, withString: string.lowercaseString)

return false

} else if textField.isEqual(textFieldYalikavak) {

textFieldYalikavak.text = (textField.text as NSString).stringByReplacingCharactersInRange(range, withString: string.uppercaseString)

return false

}

return true

}

If you don’t want to affect other textfields you should return true end of

the shouldChangeCharactersInRange function.

https://gist.github.com/fatihyildizhan/ac5f476aebd306b0580a1fa069f153a3

以上是 总是(强制)输入小写或大写字母-iOS Swift 的全部内容, 来源链接: utcz.com/qa/403070.html

回到顶部