Question

I'm creating sibling of UITextField, but with UIDatePicker instead of a keyboard.

I want multiple such controls to play nicely with each other and also standard UITextField (i.e. swap keyboard for date picker when my control is activated, and hide date picker when a text field is activated).

One thing that confuses me is handling of first responder status. UIDatePicker doesn't seem to ask to become the first responder. Should it? Can I rely on it not becoming first responder and hide date picker when my own control is asked to resign first responder?

Should I set UIDatePicker (or anything else) as my control's nextResponder? I don't want to handle any events, I just want to make sure that my control steals and resigns focus when necessary.

(I'm not using nibs in this case)

Was it helpful?

Solution

Override the resignFirstResponder method in your class, write your hide-UIDatePicker code in it, after checking the instance is the category of your sibling class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top