Search code examples
iosswiftuipickerviewuidatepicker

Is there a way to stop UIDatePicker from scrolling/rotating?


So i want to replicate choosing a date in calendar app, i create a view that is showed/hidden if user taps on date label but if user taps on date label and flics picker and then taps on label to hide it you can still hear and feel picker scrolling/rotating.

I have tried this separately and combine:

datePicker.isHidden = true

datePicker.isEnabled = false

datePicker.date = selectedDate

datePicker.setDate(selectedDate, animated: false)

I think this can be achieved with removing UIDatePicker and adding it again to View but i would not like to go that path.


Solution

  • Could not find a solution so ended up using UIPickerView, works good. pickerView.selectRow(0, inComponent: 0, animated: false) will stop picker from spinning.