cortices
cortices

Reputation: 373

How can I make a UIPickerView like a UIDatePicker?

I have a custom UIViewController subclass which acts as Datasource and Delegate for a UIPickerView which I would like to serve two different purposes, as each are simple enough, and don't really warrant separate files. One operation must be as a custom picker, and this works fine. However, for the other operation, I want it to act just like a UIDatePicker.

The problem is, UIDatePicker is a subclass of UIControl, not UIPickerView. Is there any sort of enum value I can set in a method (or other way) that will set the UIPickerView to act as a date picker? Or do I have to make two completely different classes and use them differently (pain in the ass)?

Upvotes: 1

Views: 1594

Answers (1)

jrturton
jrturton

Reputation: 119242

It would be far simpler just to have a UIPicker and a UIDatePicker, and just hide the one you don't need. UIDatePicker has all sorts of complexities for handling international date formats and calendars which you don't want to reinvent.

Upvotes: 5

Related Questions