我有如下代码。
override func viewDidLoad() {
super.viewDidLoad()
// Some setup
button.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
}
override func handleInputModeList(from view: UIView, with event: UIEvent) {
if event == onlyTouchUpEvent {
// do something
} else {
super.handleInputModeList(from: view, with: event)
}
}
在上面的handleInputModeList
代码中,在if条件下写什么,以便块只在事件触摸到UpInside 时执行
func handleInputModeList(来自:UIView,带有:UIEvent(用于处理与键盘相关的事件。支持与用户启用键盘列表的交互。
但您正在尝试添加UIControl.Event.touchUpInside.
您可以执行以下操作来观察touchUpInside UIControl.Event
override func viewDidLoad() {
super.viewDidLoad()
// Some setup
button.addTarget(self, action: #selector(handleInputTouchUpInside), for: .touchUpInside)
}
@objc func handleInputTouchUpInside() {
print("UIControl.Event.touchUpInside")
}