Thread 1: "-[_UIDatePickerIOSCompactView setHighlightsToday:]: unrecognized selector sent to instance"

Viewed 1484

I'm getting crash reports from iOS 14, from using setHighlightsToday with the UIDatePicker.

Thread 1: "-[_UIDatePickerIOSCompactView setHighlightsToday:]: unrecognized selector sent to instance"

I can't see a fix for highlighting today?

I know I need to also check for the selector being available.

1 Answers

You can try this.

 if #available(iOS 13.4, *) {
       datepicker.preferredDatePickerStyle = .wheels
       datepicker.setValue(false, forKeyPath: "highlightsToday")
  }
Related