Under iOS 14, the date/time pickers in my app are broken. Nothing changed in the project. They're defined in a storyboard and worked fine until I updated a few days ago.
Now they're not spinners; they're large grey boxes with static text in them.
UPDATE: Apple broke existing projects by defaulting date/time pickers' style to "automatic", instead of "wheel" (the only style that previously existed, and for which everyone's existing screen layouts were designed). See Sanzio's answer below.
To add some additional information to Oscar's answer...
UIDatePicker
now has three different styles, as per documentation here and here. The date picker's style is accessible by the .preferredDatePickerStyle
property which can be set to four different cases:
.automatic
- A style indicating that the system picks the concrete style based on the current platform and date picker mode..compact
- A style indicating that the date picker displays as a label that when tapped displays a calendar-style editor..inline
- A style indicating that the date pickers displays as an inline, editable field..wheels
- A style indicating that the date picker displays as a wheel picker.If you want things to look how they did pre iOS 14, stick with the .wheels
style. It is also worth noting that not all styles can accommodate all date and time settings, hence why you can only set a preferred style.
Lastly, this property is only available in iOS 13.4 or newer, so you will have to accomplish version control with something like:
if #available(iOS 13.4, *) {
yourDatePicker.preferredDatePickerStyle = UIDatePickerStyle.automatic
} else {
// Fallback on earlier versions
}
if #available(iOS 13.4, *) {
datePicker.preferredDatePickerStyle = .wheels
}
If anyone is looking for Objective-C:
if (@available(iOS 13.4, *)) {
datePicker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With