UIDate Picker valuechanged does not update the first spin, but does every spin after.. iOS

前端 未结 8 2074
野的像风
野的像风 2021-02-12 14:37

I have a UIDate Picker embedded in a static TableViewCell and at the moment I disabled most of the code except the code responsible for the date picker.

I\'m using t

8条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-12 15:34

    Time ago I found another problem that somehow resembles this one. It was about presenting a view controller from within the tableView:didSelectRowAtIndexPath: and the problem was that it was taking lots of time for the new controller to actually show up. One of the workarounds turned out to be using dispatch_async on the main queue. The same worked for me in this case.

    In my viewDidLoad, I asynchronously dispatched the picker setup code on the main queue and, in my case, it started to respond to the valueChanged event even on the first pick:

    DispatchQueue.main.async {
        self.pickerView.datePickerMode = .countDownTimer
        self.pickerView.minuteInterval = 5
        self.pickerView.countDownDuration = 15
    }
    

提交回复
热议问题