Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
iOS UIDatePicker in UIDatePickerMode.countDownTimer value changed bug
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Create a DatePicker
let datePicker: UIDatePicker = UIDatePicker()
// Posiiton date picket within a view
datePicker.frame = CGRect(x: 10, y: 50, width: self.view.frame.width, height: 200)
// Set some of UIDatePicker properties
datePicker.backgroundColor = UIColor.white
datePicker.datePickerMode = UIDatePickerMode.countDownTimer;
// Add an event to call onDidChangeDate function when value is changed.
datePicker.addTarget(self, action: #selector(ViewController.datePickerValueChanged(_:)), for: .valueChanged)
// Add DataPicker to the view
self.view.addSubview(datePicker)
}
// Not called the first time
func datePickerValueChanged(_ sender: UIDatePicker){
print("Selected value \(sender.countDownDuration)")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
@yuv4ik

This comment has been minimized.

Copy link
Owner Author

@yuv4ik yuv4ik commented Mar 20, 2017

Just reported to Apple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment