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?
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With