Weird Issue with UIDatePicker

Hello All,

I've been using a UIDatePicker in my application since launch and it has been working without issue. Sometime in the past 4-6 Weeks I've had users reporting an intermittent problem where it does not work, at this stage I can not confirm if it's happening only on newer versions of the app, this shouldn't be the case as the code base has not changed at all for anything related to the UIDatePicker.

I have seen it happen in the wild once on a friend's App Store Version of my app, on his iPhone he would move the UIDatePicker and the date would change in the picker view, but it wouldn't be reflected elsewhere in the app indicating that the UIDatePicker isn't sending data through to other components, in this case the UITextField. However on my device, two devices and the iOS Simulator, all on the same iOS Version, all with the latest version of the app, this issue did not occur.

Code snippets are as follows:

    // Setup Date Picker
    datePicker.datePickerMode = .date
    datePicker.addTarget(self, action: #selector(AddWorkDayViewController.datePickerChanged(sender:)), for: .valueChanged)
     
    // Set Date Picker Style
    if #available(iOS 13.4, *) {
      datePicker.preferredDatePickerStyle = .wheels
    } else {
      // Fallback on Earlier Versions
    }
     
    //Setup Date Toolbar
    dateToolbar.barStyle = .default
    dateToolbar.isTranslucent = true
    dateToolbar.sizeToFit()
    let doneButton = UIBarButtonItem(title: "done".localized(), style: .done, target: self, action: #selector(AddWorkDayViewController.doneTouched))
    let spaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
    let todayButton = UIBarButtonItem(title: "today".localized(), style: .done, target: self, action: #selector(AddWorkDayViewController.todayTouched))
    dateToolbar.setItems([todayButton, spaceButton, doneButton], animated: false)
    dateToolbar.isUserInteractionEnabled = true
     
    // Assign Date Picker and Date Toolbar to Date Label
    dateLabel.inputView = datePicker
    dateLabel.inputAccessoryView = dateToolbar
// Called When User Changes UIDatePicker

@objc func datePickerChanged(sender: UIDatePicker) {
    let pickerDate = sender.date
    date = pickerDate
    let dateFormatted = date.toFormat(settings.dateFormatLong)
    dateTextField.text = dateFormatted
  }

Any ideas on where to start with this? Given it happens on some devices and not others it's quite troublesome to diagnose. On the device I saw it happen on I checked accessibility settings, rebooted the device, etc. and could not figure out why it was behaving this way.

Thank you!

Hi, I do have the same issues with some of my users. Did you manage to find out what was going on?

Weird Issue with UIDatePicker
 
 
Q