Saturday, November 21, 2026
HomeiOS Developmentios - Bizarre Subject with UIDatePicker

ios – Bizarre Subject with UIDatePicker

[ad_1]

I have been utilizing a UIDatePicker in my utility since launch and it has been working with out challenge. Someday previously 4-6 Weeks I’ve had customers reporting an intermittent drawback the place it doesn’t work, at this stage I cannot affirm if it is occurring solely on newer variations of the app, this should not be the case because the code base has not modified in any respect for something associated to the UIDatePicker.

I’ve seen it occur within the wild as soon as on a pal’s App Retailer Model of my app, on his iPhone he would transfer the UIDatePicker and the date would change within the picker view, but it surely would not be mirrored elsewhere within the app indicating that the UIDatePicker is not sending knowledge by means of to different elements, on this case the UITextField. Nonetheless on my system, two units and the iOS Simulator, all on the identical iOS Model, all with the most recent model of the app, this challenge didn’t happen.

Code snippets are as follows:

    // Setup Date Picker
    datePicker.datePickerMode = .date
    datePicker.addTarget(self, motion: #selector(AddWorkDayViewController.datePickerChanged(sender:)), for: .valueChanged)
     
    // Set Date Picker Type
    if #accessible(iOS 13.4, *) {
      datePicker.preferredDatePickerStyle = .wheels
    } else {
      // Fallback on Earlier Variations
    }
     
    //Setup Date Toolbar
    dateToolbar.barStyle = .default
    dateToolbar.isTranslucent = true
    dateToolbar.sizeToFit()
    let doneButton = UIBarButtonItem(title: "accomplished".localized(), model: .accomplished, goal: self, motion: #selector(AddWorkDayViewController.doneTouched))
    let spaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, goal: nil, motion: nil)
    let todayButton = UIBarButtonItem(title: "at this time".localized(), model: .accomplished, goal: self, motion: #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
// Known as When Consumer Modifications UIDatePicker

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

Any concepts on the place to begin with this? Given it occurs on some units and never others it is fairly troublesome to diagnose. On the system I noticed it occur on I checked accessibility settings, rebooted the system, and many others. and couldn’t work out why it was behaving this fashion.

Thanks!

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments