Anokrize Anokrize - 7 months ago 14
Swift Question

Textfield delegate swift

currently I am trying to detect when a textield gets tapped.
So I am having multiple textfields and if one of them gets the focus then I want to call a function.
Currently I tried it with this code:

func textFieldDidBeginEditing(textField: UITextField!) { //delegate method
print("Test")
}


But this only works if the user starts writing. I want to print something if the textfield gots the focus (its getting tapped).

Does somebody know how to handle this?

Answer

Use this function

  func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool
{
}