2

Recently I have put a breakpoint in a UIViews method

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

}

method and checked if the compiler stops here when a user taps on the UIView while voiceover is on, but it never came to the breakpoint, does anyone know what gets called and how the touch can be intercepted?

CodeChanger
  • 7,953
  • 5
  • 49
  • 80
Shabarinath Pabba
  • 1,359
  • 2
  • 13
  • 22

3 Answers3

3

The standard hitTest mechanism is not used when VoiceOver is on. Instead, UIView has an _accessibilityHitTest:withEvent: method, but unlike macOS, it is private and can't easily be overridden or called.

Similar to hitTest, _accessibilityHitTest uses _accessibilityPointInside:withEvent:, which, in turn, calls pointInside:withEvent: (which is public).

aheze
  • 24,434
  • 8
  • 68
  • 125
cetcet
  • 2,147
  • 2
  • 15
  • 15
-1

First of all, note that users must double-tap to "activate" or "tap" a view when VoiceOver is enabled. If you still aren't hitting hitTest:…, then break on acccessibilityActivate(). This is the default accessibility action triggered by a double-tap. You may also be interested in the activationPoint, which is the default location of the simulated touch VoiceOver emits upon activation. Note that the activation point isn't relevant to all VoiceOver interactions (eg. adjustable controls).

Justin
  • 20,509
  • 6
  • 47
  • 58
  • if you activate an accessible element, it means that you fire `accessibilityActivate` in which you define your code. But what is the interest of `accessibilityActivationPoint` since the previous method must do whatever you desire ? In a custom element containing others, VoiceOver activates the focused one, doesn't it ? I really do not understand how this `activationPoint` could work and even after reading the doc. Anyway, this kind of behavior should implement accessibility actions in my view... – XLE_22 Sep 24 '18 at 11:52
  • @XLE_22 `activationPoint` is useful for elements that do not explicitly implement `accessibilityActivate`. – Justin Sep 25 '18 at 14:43
  • I must admit I don't understand how `activationPoint` could work because, in my understanding, a double tap activates only the focused element. VoiceOver doesn't know what other elements may be inside this selected element that encompasses all of them. So, how VoiceOver could interpret those inside elements that he doesn't know ? – XLE_22 Sep 25 '18 at 14:55
-3

The hit-test view is given the first opportunity to handle a touch event. If the hit-test view cannot handle an event, the event travels up that view’s chain of responders as described in “The Responder Chain Is Made Up of Responder Objects” until the system finds an object that can handle it. Please look at this.

Community
  • 1
  • 1
Gour
  • 50
  • 8