11

I have coded a simple UIDatePicker with minimum and max dates.

I want the datepicker to NOT show the unavailable dates, not only disable them.

Actual: you are able to scroll through all the unavailable dates, but when you rest on an unavailable date, the date picker scrolls to closest available date which is good but not good enough.

Expected: I would like to remove the unavailable dates all together from the datepicker, so that scrolling throught them is not even enabled.

B-Man
  • 2,209
  • 3
  • 22
  • 35
  • How will you handle the fact that the components can be adjusted independently? Suppose your minimum is 1 December 2013, and the components are currently on 10 October 2014. 2013 is a valid year, so must appear on the components, but if the user selects 2013 the resulting date (10 October 2013) will be before your minimum. – pbasdf Oct 09 '14 at 23:43
  • I understand... but the same problem occurs even within a valid time (feks 31 jan shifting to 31 feb would make it scroll which is fine). So at least the unavailable years should disappear. a lot less scrolling that is :) But i guess that is not possible? – B-Man Oct 10 '14 at 12:50
  • 1
    I was thinking further - you might be able to implement it as a UIPickerView rather than UIDatePickerView. You would have to use the `pickerView:didSelectRow:inComponent:` method to add/remove rows from the year/month/day components according to what would be valid. I don't know whether that would work, and there might be some ugly animation consequences... – pbasdf Oct 10 '14 at 13:06
  • Yeah i already considered that, but then you would need to manually "hardcode" a whole calendar to take all month and leap years and all that into consideration. Plus the ugly animation stuff hehe. Anyway, thanks for your input :) i guess I will have to live with it. – B-Man Oct 10 '14 at 14:10

0 Answers0