It’s not possible. There is a date property for the initial date. If nil it defaults to "now". If you try to use something like Date.distantPast it actually sets the date to December 31, 1. That’s year 1.
I suggest filing an enhancement request with Apple.
In the meantime you can use your own button next to a label. Have the button show a UIDatePicker with preferredDateStype set to .inline. With the right setup you can support having a "nullable" date. I do something similar in one of my apps.
2
Answers
It’s not possible. There is a
date
property for the initial date. Ifnil
it defaults to "now". If you try to use something likeDate.distantPast
it actually sets the date to December 31, 1. That’s year 1.I suggest filing an enhancement request with Apple.
In the meantime you can use your own button next to a label. Have the button show a
UIDatePicker
withpreferredDateStype
set to.inline
. With the right setup you can support having a "nullable" date. I do something similar in one of my apps.You can use pikerView like that:
Declare your array of months(or what you prefer), conform your controller to UIPickerViewDelegate an UIPickerViewDataSource:
This is the result: