itstrueimryan itstrueimryan - 1 year ago 128
Swift Question

iOS - hook into .EditingDidEndOnExit

I have a series of form fields (UITextField) that have as their "Done" action (which I changed to "Next") the ability to set the firstResponder to the next field down the line, such that when a user is filling out the field they can click next to keep progressing:

fields[i-1].addTarget(fields[i], action: "becomeFirstResponder", forControlEvents: UIControlEvents.EditingDidEndOnExit)

However, in the middle of the form I have a field with a datePicker as the inputView, and I want that same functionality when the user selects a date:

[![enter image description here][1]][1]

So basically, the user would select a date and the .EditingDidEndOnExit would fire, which would be handled appropriately by the code above.

Answer Source

The date picker emits .ValueChanged when the user rotates a wheel. So hook that to whatever you hooked that text field's .EditingDidEndOnExit to. Or hook it to something else. But the point is that you can respond directly to the date picker being changed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download