开发者

Prevent VoiceOver revealing views that are beneath a larger transparent view

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 underneat开发者_运维百科h 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.


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


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)


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;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜