@IBAction func dat(sender: UITextField) {
var datePickerView:UIDatePicker = UIDatePicker()
datePickerView.datePickerMode = UIDatePickerMode.Date
sender.inputView = datePickerView
datePickerView.addTarget(self, action: Selector("datePickerValueChanged:"), forControlEvents: UIControlEvents.ValueChanged)
}
func datePickerValueChanged(sender: UIDatePicker) {
var dateformatter = NSDateFormatter()
dateformatter.dateStyle = NSDateFormatterStyle.MediumStyle
ld.text = dateformatter.stringFromDate(sender.date)
}
@IBAction func ett(sender: UITextField) {
var datePickerView : UIDatePicker = UIDatePicker()
datePickerView.datePickerMode = UIDatePickerMode.Time
sender.inputView = datePickerView
et = sender
datePickerView.addTarget(self, action: "handleDatePicker:", forControlEvents: UIControlEvents.AllEvents)
我想只显示当前日期,例如约会固定。只能显示当前日期。如何写逻辑
答案 0 :(得分:6)
只需添加以下行:
datePickerView.minimumDate=NSDate()
希望它有助于.... :)