jola
jola

Reputation: 1115

Background VoiceOveraccessibility focus on a UICollectionView

I have a problem with voiceover on a collectionview. I have a fullscreen (minus navigation bar) UICollectionView that contains 5 cells. Each cell contains a view with isAccessibilityElement=true.

When VoiceOver is activated the title in the navigation bar is focused. If I then move focus by left/right swiping each of the cell items is focused, one by one, just as one would expect. The problem is if I instead move focus by dragging my finger downwards on the screen. Then the background of the screen (i.e. the collection view's area) receive focus when the finger is outside of any of the cells.

Is there a way to turn this off?

I have tried:

class MyViewController: UICollectionViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        // A. This makes everything in the collection inaccessible, both 
        // background and cell content. 
        //collectionView?.accessibilityElementsHidden = true

        // B. This has no effect
        //collectionView?.isAccessibilityElement = false
    }  
...

I would expect B to work, but it doesn't (nothing happens). I've also tried various other things like: self.view.isAccessibilityElement = false, self.view.superview.isAccessibilityElement = false without success.

Hope someone can help!

Upvotes: 6

Views: 1558

Answers (1)

XLE_22
XLE_22

Reputation: 5671

Traversing a collection view with VoiceOver is like traversing an accessible element whose trait property is adjustable.

Each element of the collection view is an UIAccessibilityElement that must be redefined inside your code.

To understand how that should be implemented, I suggest you take a look at the WWDC 2018 - Deliver an exceptional accessibility experience video whose content is perfectly summarized here and whose presented example can be downloaded... following this kind of programing won't focus any object in the background.

Upvotes: 0

Related Questions