UIAutomation Nested Accessibilty Elements Disappear from Hierarchy

前端 未结 1 692
孤城傲影
孤城傲影 2021-02-13 21:40

I have a view with two subviews a button and an Image, I turn on accessibility and set the label on the subviews and I can see the hierarchy by calling

UIATarge         


        
相关标签:
1条回答
  • 2021-02-13 22:39

    Straight from the iOS docs Accessibility Guide

    Make the Contents of Custom Container Views Accessible If your application displays a custom view that contains other elements with which users interact, you need to make the contained elements separately accessible. At the same time, you need to make sure that the container view itself is not accessible. The reason is that users interact with the contents of the container, not with the container itself.

    To accomplish this, your custom container view should implement the UIAccessibilityContainer protocol. This protocol defines methods that make the contained elements available in an array.

    The following code snippet shows the partial implementation of a custom container view. Note that this container view creates the array of accessible elements only when methods of the UIAccessibilityContainer protocol are called. As a result, if iPhone accessibility is not currently active, the array is not created.

    0 讨论(0)
提交回复
热议问题