gpt4 book ai didi

swift - UIDataPicker 到 TextField

转载 作者:可可西里 更新时间:2023-11-01 01:35:48 28 4
gpt4 key购买 nike

我为 UIDatePicker 编写了这段代码到 UITextField 中:

@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)
}

但我有这个错误:

Type 'ViewController' has no member 'datePickerValueChanged'

我该如何修复这个错误?

最佳答案

dataPickerValueChanged or datePickerValueChanged?

检查你的代码

关于swift - UIDataPicker 到 TextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37462590/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com