30

Summary: I want to replicate the accessibility behaviour of a UIAlertView, where the background view is still visible but VoiceOver does not interact with it.

Detail: I have implemented accessibility for an iPhone app, but have one problem remaining. In some cases I display a large view on top of all others (partially transparent, covering most of the original view) containing labels and a close button. i.e. basically a custom popup/alert view. The problem is, VoiceOver continues to reveal the views/controls underneath it.

One method to prevent the hidden views from being revealed by VoiceOver is to set the whole custom view background to be accessible. However, this isn't really what we want as this containing view shouldn't really be interacted with by the user, only its subviews (labels/buttons) should.

Chris Miles
  • 7,346
  • 2
  • 37
  • 34
  • 2
    Did you ever figure out a solution for this? I'm trying to solve the same problem right now. – l8nite Jul 15 '11 at 20:50
  • Nope. Had to stick with making the custom view background accessible. – Chris Miles Jul 19 '11 at 06:59
  • @ChrisMiles Just wanted to check, whether did you ever find a solution for this. And how are you making the custom view background accessible ? – Manoj Aug 13 '13 at 11:53
  • self.view.isAccessibilityElement = YES; Are you doing something like this? If yes, there is an issue coz I cant access the other UI objects for that receiver. eg. buttons, sliders on the transparent view. – Manoj Aug 13 '13 at 12:00
  • I seem to have the opposite problem! I have a transparent overlay view over my (playing video) main view, that contains buttons etc (you know, the normal play/pause thing) but as soon as my overlay gets fully transparent (alpha 0.0) accessibility no longer reveals my buttons. What's going on here? – Motti Shneor Dec 11 '16 at 17:14
  • It's 2018 and same problem... Apple should fix this. – User Jul 29 '18 at 13:12
  • Setting `view.isAccessibilityElement = true` also didn't help – User Jul 29 '18 at 13:15

4 Answers4

27

I think you should use this on your top laying view:

Objective-C

- (BOOL)accessibilityViewIsModal {
    return YES;
}

Swift

accessibilityViewIsModal = true

This makes every element of the View Controller that is hidden unaccessible.

An implementation could be to set it to true when you show the view and set it to false when you dismiss that view.

More info

Note: Requires iOS5 and up

JaySH
  • 546
  • 6
  • 15
6

Swift 4

In swift try this: Before your view is presented setup your viewController’s view like this:

yourViewController.view.accessibilityViewIsModal = true

Also try setting the self.view.accessibilityViewIsModal to true in viewWillAppear

override func viewWillAppear(_ animated: Bool) {
   super.viewWillAppear(animated)
   view.accessibilityViewIsModal = true
}

It also might help if you send a screen chances notification when your modal or pop up view is appearing by adding this to the viewWillAppear:

UIAccessibility.post(notification: .screenChanged, argument: nil)
Ramin
  • 335
  • 4
  • 14
-2

You can set the following properties on the view overlaying the background:

view.isAccessibilityElement = false;
view.isAccessibilityViewModal = true;

Does this work?

In obj-c:

    view.isAccessibilityElement = NO;
    view.accessibilityViewIsModal = YES;
Vadim F.
  • 881
  • 9
  • 21
XCode Warrier
  • 765
  • 6
  • 20
-3

When you hide the item, you can set isAccessibilityItem to NO.

Jason
  • 14,517
  • 25
  • 92
  • 153
  • I guess you mean `isAccessibilityElement`. I don't think this setting applies to a view's subviews does it? If not, I would need to apply this setting change to all subviews that are underneath the partially transparent full screen view, which would be a bit unwieldy. – Chris Miles Aug 09 '11 at 05:56