iOS 12 DatePicker value changed issue

There is a date picker which is the @IBOutlet. It is an input view of my text field

myTextField.inputView = picker


The problem is that when I scroll datepicker - it scrolls okay but value in the text field is not changing. The text field is still empty not matter how much times I try to change it.


The biggest problem is that this issue reproduces rarely "in a wild" and seems like only on iOS 12. Only several users of my app reproducing this issue always when all other can't see it even when they are trying to.
May it be an iOS12 issue with the date picker??


The code was working well and was not touched, but this issue start to shows up when ios 12 released.
This issue is displayed in the the videos below
https://drive.google.com/open?id=1b0ojTNzeJM76bjezRVTfBsMZcYCeUs2X
https://drive.google.com/open?id=1namJVdaH4hax74SXWvpU8-0ScBacwOsR

Replies

Did you set a target for valueChanged in the picker ; this should update the textField.


Note that update occurs ONLY after you CHANGED the value in the picker.

Yes.


As I said, only several users of my app reproducing this issue always when all other can't see it even when they are trying to. If this method (or something like that) wasn't setted - is would not work for all not only for 3 special ones.

Could you show the complete code for the class involving the textField ?


Note: could not access your videos. I get a request for authorization. But never received the mail from Google providing authorization. What message do they get ? I suppose you have checked they all run IOS12.

I gave u the access to video. Please check it again.


That 3 users told me that their operaion system is IOS12.
Showing the complete code is difficult 'cos there is many abstractins and some part of logic is in the storyboards. I can try to show u the parts of it as much as possible.

// MARK: - UIPickerViewDelegate // UIPickerViewDataSource
extension MyTableViewController: UIPickerViewDelegate, UIPickerViewDataSource {
  func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
  }

  func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return Date().year - Constants.startYear + 1
  }

  func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    return (Constants.startYear + row).description
  }

  func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    datePickerWillReturn(row: row)
  }
}

//delegate for "Done" button on toolbar
extension MyTableViewController: PickerViewAccessibleTableViewCellDelegate {
  func didSelectDoneButton() {
    datePickerWillReturn(row: pickerView.selectedRow(inComponent: 0))
  }
}


  private func datePickerWillReturn(row: Int) {
    /*  // this method is just setting selected row value into cell textfield 
     and it is called in two times - button "Done" and from picker delegate */
  }


and there is the picker table view cell


protocol PickerViewTableViewCellDelegate: class {
  func didSelectDoneButton()
}

class MyTableViewCell: UITableViewCell {
  weak var delegate: PickerViewTableViewCellDelegate?

  public func pickerView(_ view: UIView) {
    let toolBar = UIToolbar()
    toolBar.barStyle = .default
    toolBar.sizeToFit()

    let doneButton = UIBarButtonItem(title: "Done".localized, style: .plain, target: self, action: #selector(didSelectDoneButton))
    let spaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
    toolBar.setItems([spaceButton, doneButton], animated: false)
    toolBar.isUserInteractionEnabled = true
    textField.inputAccessoryView = toolBar

    view.frame.size.height = Constants.defaultKeyboardHeight
    textField.inputView = view
  }

  public func presentPickerView() {
    textField.becomeFirstResponder()
  }

  private var textField = UITextField(frame: CGRect(x: 0, y: 0, width: 1, height: 1))

  @objc private func didSelectDoneButton() {
    delegate?.didSelectDoneButton()
    textField.resignFirstResponder()
  }

  override func awakeFromNib() {
    super.awakeFromNib()
    self.textField.isHidden = true
    self.contentView.addSubview(self.textField)
  }
}


PickerViewTableViewCellDelegate is setted in viewDidLoad of MyTableViewController and all delegates are setted.
And this code was checked by several other developers and they can't find the reason