How to accept only Month and Year using DatePicker in iOS

2 Solutions Collect From Internet About “How to accept only Month and Year using DatePicker in iOS”

Choice-1

Objective-C

yourDatepicker.datePickerMode = UIDatePickerModeDate;

Swift

 yourDatepicker.datePickerMode = UIDatePickerMode.Date

Swift3

yourDatepicker.datePickerMode = .date

the another modes are

  • UIDatePickerModeTime,
  • UIDatePickerModeDate,
  • UIDatePickerModeDateAndTime,
  • UIDatePickerModeCountDownTimer

Choice-2

the above method not working well, then check this link

Not really an answer but an alternative: why not use a picker for month an a picker for year like most apps do (also on websites the equivalent a popupmenu is used)