Anokrize Anokrize - 1 year ago 147
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

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 Source

Use this function

  func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download