Determine whether a Date only inline DatePicker, is currently in a calendar view mode, or a shortcut month/year rotary view mode

Viewed 66

Currently, I have an inline style DatePicker with Date only mode.

calendar view mode

enter image description here

The DatePicker is observing value changed event, and will execute datePickerValueChanged if value changed event happen.

For the above screenshot, if I try to tap on the date 16, the following function callback will be executed

@IBAction func datePickerValueChanged(_ datePicker: UIDatePicker) {
    print(">> datePickerMode => \(datePicker.datePickerMode.rawValue)")
    print(">> datePickerStyle => \(datePicker.datePickerStyle.rawValue)")
}

However, if I were to tap on the local top left "February 2021" (Will not cause datePickerValueChanged), it will become the following

month/year rotary view mode

enter image description here

If I rotate the rotary view, the same datePickerValueChanged will be executed as well!

I would like to perform some action, only if user tap on a date during calendar view mode.

Since both of the views will trigger value change event, and checking for datePicker.datePickerMode and datePicker.datePickerStyle. doesn't help much.

Do you have any idea, how I can determine whether a Date only inline DatePicker, is currently in a calendar view mode, or a shortcut month/year rotary view mode?

0 Answers
Related