UITextFieldDelegate method only works if we enter the data to textfield through the keyboard. But we I change the value of textfield. text from any button action none of its delegate methods is triggering. I have also tried to add the objective fun to listen for value change but they also only work when textfield received input from the keyboard.
override func viewDidLoad() {
super.viewDidLoad()
txtMinute.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)
}
@objc func textFieldDidChange(_ textField: UITextField) {
print(textField.text)
enableEditButton()
}
@IBAction func change_minutes(_ sender: Any) {
txtMinute.text = "123"
}
Any suggestion on how to list change in for textfield on button action?
2
Answers
Try the following:
TextField Delegate Methods only called if you giving input through Keyboard,Suppose if you want those Delegate methods to be called while using custom NumPad you need to call Manually Like Below