I have created an action that changes the color of UITextField
. But when I tap on the textfield it changes color but the keyboard does not appear. The keyboard appears only on second tap. Is this an issue of first responder? I'm new to Swift
programming.
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
textfield1.addTarget(
self,
action: #selector(textfield1.handleFrontTap(_:)),
forControlEvents: UIControlEvents.EditingDidBegin
)
}
func handleFrontTap(sender: UITextField) -> Void {
print("tap working")
setColor()
self.textfield1.endEditing(true)
}
Don't you think it's your self.textfield1.endEditing(true) that's cancelling the keyboard showing?