Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VoiceOver parent and child views as accessibility elements

I have a simple UIView hierarchy. There is a parent view A which contains view B and C. If I set all views as accessibility element, only view A is accessible. Views B and C are not clickable. I need all views (A, B and C) to be accessibility elements.

I know you can achieve that by putting all views (A, B and C) at the same level, but view hierarchy in my app does not allow any changes.

Do you have any solution for that?

like image 745
pawel221 Avatar asked Aug 09 '16 11:08

pawel221


2 Answers

1) Make all your views i.e A, B, C as accessibilityElement.

   A.isAccessibilityElement = true
   B.isAccessibilityElement = true
   C.isAccessibilityElement = true

2) If your parent view is parentView, then set all these views as its AccessibilityElements

parentView.accessibilityElements = [A, B, C]

PS :- accessibilityElements creates a group of all elements mentioned in array. This is also used to change the order of elements. But the only thing you have to keep in mind is to mention all the elements you have in parentView to this array otherwise the element will get skip while swiping on views.

like image 97
Preeti Rani Avatar answered Oct 13 '22 20:10

Preeti Rani


Is view A an accessibility element? For subviews to be accessible, the containing view must not be an accessibility element.

view.isAccessibilityElement = false

If you need the third view, A, to be accessible, then make it a sibling view of B and C.

like image 31
Justin Avatar answered Oct 13 '22 20:10

Justin