79338171

Date: 2025-01-08 06:53:31
Score: 0.5
Natty:
Report link

7 years later and I ran into this problem.

Modifying the subviews' isUserInteractionEnabled value did not work, and my ViewControllers were already set to full screen.

I made a sample project of a view controller that segues to another view controller (link to partial project below).

Solution (the important part)

In ViewControllerB, override UIResponder::touchesBegan(), UIResponder::touchesMoved(), and UIResponder::touchesEnded(). If you don't, the responder will not look at ViewControllerB as an acceptable ViewController, go up the hierarchy to ViewControllerA and call those overriden methods. Note: At minimum, you only need to override touchesBegan, but there's no reason not to implement all three methods.

Project gist link: https://gist.github.com/krishkalai07/87cfa63c13306da5eb6289349872e4fe

Usage (the proof)

  1. Make a project,
  2. Replace Main.storyboard with the one from the gist
  3. Optionally delete ViewController.swift
  4. Run and tap for a successful run
  5. Comment all of ViewControllerB::touchesBegan(), ViewControllerB::touchesMoved(), and ViewControllerB::touchesEnded()
  6. Run and tap and notice in the console, it shows View Controller A even though it segued to View Controller A
Reasons:
  • Blacklisted phrase (1): did not work
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: sudomeacat