Custom control in iOS 13 modal screens cancels touch

I have a custom control (a directional button with four parts; up, down, left, right) that uses beginTracking, continueTracking, etc.


When this control is in a modal view controller on iOS 13, any initial taps on the control work well, but after moving the touch even a small amount, cancelTracking is called.


While I can set the view controller to go full-screen, I'd like to keep the iOS 13 behavior of being able to dismiss it with the gesture. But it seems that that gesture is overriding any tracking of a control. The control is set to have isExclusiveTouch to 'true'.



NOTE: This also happens with standard iOS controls. e.g. a standard button. Touch the button and all is well. But once you track outside the button, it starts moving the view controller.

Answered by InstantInteractive in 407690022

Got lucky and found a solution. One can add this to their custom control implementation:


  override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
      false
  }


This prevents the modal gesture from canceling the tracking on the control. The modal gesture can still be used in areas outside the control to dimiss the modal.

Accepted Answer

Got lucky and found a solution. One can add this to their custom control implementation:


  override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
      false
  }


This prevents the modal gesture from canceling the tracking on the control. The modal gesture can still be used in areas outside the control to dimiss the modal.

Thanks for feedback. Please close the thread on your answer.

Custom control in iOS 13 modal screens cancels touch
 
 
Q