Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a UIDatePicker display specific dates?

My application has a need to let the user choose a date from a list of dates conforming to a certain pattern. For instance, they may need to choose a monday from a list Monday's for a month. Is there a way to get a UIDatePicker to limit date choices to a certain subset or should I just use a UIPickerView?

like image 586
drewh Avatar asked Sep 11 '08 15:09

drewh


People also ask

How do I change the date picker on my Iphone?

Go to the Storyboard and drag a Label to the main View. Double-click the Label and give it a title of "MM/DD/YY HH:MM.". Next, drag a Date Picker below the label. Select the Resolve Auto Layout Issues button and select Reset to Suggested Constraints.

What is DatePicker in Swift?

DatePicker is a control used in iOS applications to get the date and time values from the user. We can allow the user to either enter the time in point or time interval. class UIDatePicker : UIControl.

What is UIDatePicker?

A control for inputting date and time values.


1 Answers

You cannot limit which dates are selectable in a UIDatePicker. You could change the date when the value changed event is sent, but since the user cannot tell which dates are "good" and which are not, it's a bad UI choice to do so.

Use a UIPickerView of your own making instead.

like image 159
millenomi Avatar answered Sep 27 '22 16:09

millenomi