UIAutomation Nested Accessibilty Elements Disappear from Hierarchy

99封情书 提交于 2019-12-05 13:55:42

问题


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

UIATarget.localTarget().frontMostApp().mainWindow().logElementTree();

I get the following for example:

1 Window

2 My View

3 My Button

3 My Image

If I then turn on accessibility and set the label for my parent view I can no longer see my button and image anywhere in the hierarchy.

I just get:

1 Window

2 My View

Why have my views disappeared?


回答1:


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.



来源:https://stackoverflow.com/questions/6200025/uiautomation-nested-accessibilty-elements-disappear-from-hierarchy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!