如何以快速语言强制某些文本字段键入小写或大写?
您应该return false进入,if block因为您已经更新了textfield。
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.
return true
shouldChangeCharactersInRange function
https://gist.github.com/fatihyildizhan/ac5f476aebd306b0580a1fa069f153a3