0

Q: Is there a built in method to summarily cancel touch events in a UIView/UIViewController

Background: I am implementing a help system in my app that will have a message box on screen, and a colored overlay over the base UI. As the user taps the message box, it will disappear, a portion of the main UI will be revealed, and a new message box describing it will show up.

The important bit is having the revealed portion of the UI be useable while still not letting the rest work or not work as needed.

I was about to make a bunch of views to act as a mask, but it would be way easier if I could dictate where touches should go based on location.

I have started looking at overriding

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

}

but as far as I have been able to find, theres no simple method to call like in a gestureRecognizer to cancel (or set a cancelled state).

solenoid
  • 954
  • 1
  • 9
  • 20
  • I'm not entirely clear on your need to implement this but I don't believe there's a simple method. There's func touchesCancelled(_ touches: Set, with event: UIEvent?) you need to look at the UITouch stack or cancelled state based on a system message like var cancelsTouchesInView: Bool { get set } – mrabins Jul 30 '17 at 15:44
  • On this link you can find possible answer https://stackoverflow.com/a/533889/1351135 – Ivan Skrobot Jul 30 '17 at 21:21
  • I had seen that and thought it was a horribly kludgy way to do it, but you are right - this may be the only way get it to work – solenoid Jul 30 '17 at 21:51

0 Answers0