0

I have a custom control (UIView subclass) that is identical to "slide to unlock" control on the lock screen.

Is there a way I can get notified when Voiceover has selected the view? Also, when it's selected the gesture recognizer is not receiving gestures, thus rendering the control useless.

Any tips? Thus far, I've set the isAccessibilityElement and labels/hints.

christo16
  • 4,843
  • 5
  • 42
  • 53
  • I know that your question has been answered but you should have a look at what Apple does with VoiceOver for their "slide to unlock". They turn it into "double tap to unlock". Otherwise, for normal sliders like volume etc you should look at the `accessibilityIncrement` and `accessibilityDecrement ` methods. – David Rönnqvist Mar 25 '13 at 13:40

1 Answers1

3

I had to do two things to make it work:

self.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction;

and added a double tap gesture recognizer that only triggers when voice is running

    UITapGestureRecognizer *doubleTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didDoubleTap:)];
    doubleTapGestureRecognizer.numberOfTapsRequired = 2;
    [self addGestureRecognizer:doubleTapGestureRecognizer];

- (void)didDoubleTap:(UITapGestureRecognizer*)tapGesture {
    if(UIAccessibilityIsVoiceOverRunning()){
        [self slideHandleToFinish];
    } }
christo16
  • 4,843
  • 5
  • 42
  • 53
  • This worked for me also. Setting UIAccessibilityTraitAllowsDirectInteraction enabled VoiceOver to receive my UISwipeGestureRecognizer. – Bryan Luby Jul 31 '12 at 00:07
  • thanks, apple say we just need to add the previous accessibilityTrais or we'll lose them (in my case i lost a lot), like this: self.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction | [super accessibilityTraits]; note is UIAccessibilityConstants.h as a comment of UIAccessibilityTraits: "When setting accessiblity traits, combine custom traits with [super accessibilityTraits]. An incorrect combination of custom traits will cause accessibility clients to incorrectly interpret the element." – meronix Dec 05 '13 at 10:40