I am new to iOS/Swift so please bear with me.
I have a TextField, timeTextField, and want to display a TimePicker on click. All this is working property but when another element is selected the app crashes why does it crash? UPDATE 1: updated code code:
func setupTimePicker(){
datePickerView.datePickerMode = UIDatePickerMode.time
datePickerView.removeFromSuperview()
timeTextField.inputView = datePickerView
datePickerView.addTarget(self, action: #selector(self.datePickerValueChanged(sender:)), for: .valueChanged)
}
func datePickerValueChanged(sender:UIDatePicker) {
var date = Date()
let calendar = Calendar.current
date = sender.date;
let hour = calendar.component(.hour, from: date)
let minutes = calendar.component(.minute, from: date)
timeTextField.text = String(format: "%02d", hour) + ":" + String(format: "%02d", minutes)
}
error:
[TestApp.ViewController pickTime:]: unrecognized selector sent to instance 0x7f9305e08e20