Setting the Datepicker in IOS to pick only the Month and Year

Paul John Parreno picture Paul John Parreno · Jun 13, 2011 · Viewed 74k times · Source

Is there any way possible to set a UIDatePicker in XCode-Interface Builder to just use the rollers of the "month" and "year" without the "day"? I've tried checking the file properties in the IB yet failed to find a solution for my problem...

Answer

Deepak Danduprolu picture Deepak Danduprolu · Jun 13, 2011

Your question mentions date and year so I it seemed like UIDatePickerModeDate would suffice but as you are looking for month and year which is not an available option. I suggest you consider using a two component UIPickerView object.

Original Answer

You can do this by changing the Mode property under Date Picker to Date in the Attributes Inspector in the right bar ( Cmd + Option + 4 ). You can also do this programmatically,

datePicker.datePickerMode = UIDatePickerModeDate;