Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
939
41
Tokyo, Japan
I am using DatePicker, and I want to know if I can set year to 2010, 2015 and so on, then the DatePicker can only be selected for year 2010 and 2015, is this possible?
 
It might be possible with a custom (supplied by you) NSCalendar object that represents the dates you want. This seems very complex though. If you simply want to allow the user to pick from a set of years why not use a UIPickerView, specify the correct number of components and use the data source to only allow the values you want?

And before you ask, no I won't supply "sample code" for you to copy and paste and then claim as your own. The documentation should be more than enough to work this out.
 
Now I just finished DatePicker, like you said, the next step is to make a PcikerView, I hope I can finish it by myself.

Thanks for your suggestion.
 
I doubt it can be used for discontinuous date ranges. Is that really what OP wants? Sounds very oddball that the date picker would go from Dec 2010 to Jan 2015. There's probably a better UI for that.
 
I doubt it can be used for discontinuous date ranges. Is that really what OP wants? Sounds very oddball that the date picker would go from Dec 2010 to Jan 2015. There's probably a better UI for that.

I can think of uses for that sort of thing. Say choosing individual dates from past Olympics/major sports championships...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.