[SOLVED: Not possible] How do I limit the range of dates in the UIDatePicker?

Discussion in 'iOS Programming' started by chrono1081, Jul 22, 2014.

  1. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #1
    Hi guys,

    I have a UIDatePicker item and I already set the minimum and maximum dates but I want only the dates between the minimum and maximum dates to display in the date picker.

    (For example if the minimum date was Jan 1 1980 and the maximum date was Jan 1 2000 I only want the dates between Jan 1 1980 and Jan 1 2000 to display in the date picker.

    Currently with minimum and maximum set any other date is visible, the date picker just scrolls back to the minimum or maximum when it is selected.

    I didn't see any method that looks like it would accomplish this. Does anyone have any ideas?
     
  2. JohnsonK macrumors regular

    Joined:
    Mar 6, 2014
    #2
    For maximum flexibility, I suggest implementing your own date picker by using an UIPickerView
     
  3. chrono1081 thread starter macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #3
    Thanks. Yea thats what it looks like I'm going to have to do.

    I'm not sure quite how to do it but I'll work on figuring it out this weekend.

    My guess is something like:

    -Initialize a picker with the correct columns and rows
    -Magically populate the rows with NSCalendar Dates
    -Handle events.

    I'll have to do some digging in NSCalendar.
     
  4. PBG4 Dude macrumors 68000

    PBG4 Dude

    Joined:
    Jul 6, 2007
    #4
    Having just seen this blow up an international deployment (not iDevice), make sure you understand how you'll be working with date / time formats.

    Part of the system I was involved with rolling out blew up in a few Asian countries due to differences between system date / time settings, what the program expected, and even the fact that AM/PM is represented by different characters in different languages. Have to do a full regression test just to change a tiny section of code to handle this issue.
     
  5. chrono1081 thread starter macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #5
    Thanks for the heads up. This app is an in house app and will only be used in the U.S. (and most likely only one state) but I will look in to it just to be safe.
     

Share This Page