ActionSheetPicker 用于 ActionSheetPicker 的无效 target/action 组合'
ActionSheetPicker Invalid target/action combination used for ActionSheetPicker'
您好,我正在尝试使用 ActionSheetPicker 让用户 select 有时间进行提醒,但我收到标题中描述的错误。这是我的代码:
SelectTime(sender: validCell) // called when tapping a date
// Time Picker
func SelectTime(sender: UIView){
//let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: , origin: sender.superview!.superview)
let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: Selector(("timePicked")), origin: sender.superview!.superview, cancelAction: Selector(("timeCanceled")))
timePicker?.minuteInterval = 5
timePicker?.locale = Calendar.current.locale
timePicker?.show()
}
func timePicked(time: Date){
dateSelected.text = formatter.string(for: time)
}
func timeCanceled(){
print("Canceled")
dismiss(animated: true, completion: nil)
}
取消代码从未被调用,当我在 timePicker 上按下取消时,它会在其下方显示另一个没有任何按钮的时间选择器。
取消时的Gif
http://www.giphy.com/gifs/l1J3zMQWJ23GpHEaY
dateSelected 也从未被调用。我做错了 select 吗?
更改此代码
func SelectTime(sender: UIView){
let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: , origin: sender.superview!.superview)
let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: Selector(("timePicked")), origin: sender.superview!.superview, cancelAction: Selector(("timeCanceled")))
timePicker?.minuteInterval = 5
timePicker?.locale = Calendar.current.locale
timePicker?.show()
}
func timePicked(time: Date){
dateSelected.text = formatter.string(for: time)
}
func timeCanceled(){
print("Canceled")
dismiss(animated: true, completion: nil)
}
在此代码中....
let timePicker = ActionSheetDatePicker(title: "Date:", datePickerMode: UIDatePickerMode.date, selectedDate: Date(), doneBlock: {
picker, value, index in
dateSelected.text = formatter.string(for: time)
print("value = \(value)")
print("index = \(index)")
print("picker = \(picker)")
return
}, cancel: { ActionStringCancelBlock in
print("cancel")
return }, origin: sender.superview!.superview)
timePicker?.minuteInterval = 5
timePicker?.locale = Calendar.current.locale
您好,我正在尝试使用 ActionSheetPicker 让用户 select 有时间进行提醒,但我收到标题中描述的错误。这是我的代码:
SelectTime(sender: validCell) // called when tapping a date
// Time Picker
func SelectTime(sender: UIView){
//let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: , origin: sender.superview!.superview)
let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: Selector(("timePicked")), origin: sender.superview!.superview, cancelAction: Selector(("timeCanceled")))
timePicker?.minuteInterval = 5
timePicker?.locale = Calendar.current.locale
timePicker?.show()
}
func timePicked(time: Date){
dateSelected.text = formatter.string(for: time)
}
func timeCanceled(){
print("Canceled")
dismiss(animated: true, completion: nil)
}
取消代码从未被调用,当我在 timePicker 上按下取消时,它会在其下方显示另一个没有任何按钮的时间选择器。 取消时的Gif http://www.giphy.com/gifs/l1J3zMQWJ23GpHEaY
dateSelected 也从未被调用。我做错了 select 吗?
更改此代码
func SelectTime(sender: UIView){
let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: , origin: sender.superview!.superview)
let timePicker = ActionSheetDatePicker.show(withTitle: "Enter time for reminder", datePickerMode: .time, selectedDate: userDate, target: self, action: Selector(("timePicked")), origin: sender.superview!.superview, cancelAction: Selector(("timeCanceled")))
timePicker?.minuteInterval = 5
timePicker?.locale = Calendar.current.locale
timePicker?.show()
}
func timePicked(time: Date){
dateSelected.text = formatter.string(for: time)
}
func timeCanceled(){
print("Canceled")
dismiss(animated: true, completion: nil)
}
在此代码中....
let timePicker = ActionSheetDatePicker(title: "Date:", datePickerMode: UIDatePickerMode.date, selectedDate: Date(), doneBlock: {
picker, value, index in
dateSelected.text = formatter.string(for: time)
print("value = \(value)")
print("index = \(index)")
print("picker = \(picker)")
return
}, cancel: { ActionStringCancelBlock in
print("cancel")
return }, origin: sender.superview!.superview)
timePicker?.minuteInterval = 5
timePicker?.locale = Calendar.current.locale