I’ve searched the interwebs to no avail… I am using MT.D and want to set a birthdate for a person using the DateElement, but the birthdate could be null, meaning that the data has not been collected yet. Anyone know how to make a DateElement accept a null value OR a date?
I’ve searched the interwebs to no avail… I am using MT.D and want to
Share
UPDATE 20140106: Since iOS7 has been released, Apple desires that date/time pickers be inline with content rather than be an action sheet, or in this case, full screen overlay. Therefore, this code is for how-to and historical purposes only.
Ok, so I rolled my own class. Personally I think the current date/time picker set up doesn’t look as professional as having the equivalent of an
ActionSheetpop up with a datepicker attached to it. Someone more experienced in MT.D may be able to figure it out, but what I did was to copy the code fromDateTimeElementandDateElementand modify it so that it has three buttons on top: The left-most button is Cancel, the right button area has “Set” and “Null” buttons. The captions for the right buttons can be set to whatever you like in the ctor of the class, but can be defaulted to “Set Date” and “No Date”.Sharing is caring!
NULLABLE DATE TIME ELEMENT
NULLABLE DATE-ONLY ELEMENT
@Miguel, Please consider adding this to MonoTouch.Dialog, as there is a very legitimate business need for null dates/date times, and this solution seems to do the trick. My code will have to be cleaned up a bit, but this works.