views:

180

answers:

1

Hi all,

I'm trying to make a UIDatePicker wich is alowing to select hours only betwen 6.00 and 17.00. The other hours shall be inactive but still visible. I think it can be done with setting up the picker calendar and then use this:

- (NSRange)maximumRangeOfUnit:(NSCalendarUnit)unit

but i'm nou sure how.

Maybe someone can help me.

Thank you!

A: 

Sorry, but UIDatePicker doesn't support setting valid time ranges like you describe. The only options are minimum and maximum dates.

You'll either need to build a custom control from scratch or try to subclass UIDatePicker, but that's not a path I'd recommend.

Kirk van Gorkom
Thank you Kirk , I still think you can set a range for a NSCalendar (see http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html#//apple_ref/occ/instm/NSCalendar/rangeOfUnit:inUnit:forDate: ), and tell UIDatePiker to use that calendar , right?
katovskii
No, that's a read only property on NSCalendar, and creating your own NSCalendar (if that's even possible) is a far worse option (localization, bugs, etc..) than just using UIPickerView to build a custom control.
Kirk van Gorkom