我将UIDataPicker
的代码写入TextField
:
@IBOutlet weak var dateTextField: UITextField!
@IBAction func textFieldEditing(sender: UITextField) {
let datePickerView:UIDatePicker = UIDatePicker()
datePickerView.datePickerMode = UIDatePickerMode.Date
sender.inputView = datePickerView
datePickerView.addTarget(self, action: ViewController.datePickerValueChanged, forControlEvents: UIControlEvents.ValueChanged)
}
func datePickerValueChanged(sender:UIDatePicker) {
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle
dateFormatter.timeStyle = NSDateFormatterStyle.NoStyle
dateTextField.text = dateFormatter.stringFromDate(sender.date)
}
但我有这个错误:
类型'ViewController'没有成员'datePickerValueChanged'
如何解决此错误?
答案 0 :(得分:2)
dataPickerValueChanged or datePickerValueChanged?
检查您的代码