handleInputModeList recognising touchUpInside envent

84 Views Asked by At

I have code like following.

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

In above handleInputModeList code, what to write in the if condition so that block only executes when the event is touchUpInside

1

There are 1 best solutions below

1
Nandish On

func handleInputModeList(from: UIView, with: UIEvent) is to handle keyboard related events. Supports interaction with the list of user-enabled keyboards.

But you are trying to add UIControl.Event.touchUpInside.

You can do below to observe 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")
}