Why doesn't UIScrollview have an accessibility area in the Interface Builder?

可紊 提交于 2019-12-07 03:09:25

问题


I've noticed that a UIScrollView doesn't have mentioned accessibility area where I can set accessibility label or accessibility. This seems to apply for activity indicators too.

Why does UIVIews, UIButtons and more have this area and not UIScrollView and UIActivityIndicatorView?


回答1:


Good question - the reason for a scroll view is that Apple don't consider it to be an accessible element.

If you look at the UIAccessibility documentation, you'll find Apple have the following to say on what counts as an 'accessible element':

The only exception to this [a view being accessible] is a view that merely serves as a container for other items that should be accessible. Such a view should implement the UIAccessibilityContainer protocol and set this property to NO.

A UIScrollView is simply a container for subviews, so its isAccessibilityElement property is set to no (hence why you don't see the accessibility options in interface builder).

So basically, when you're using a scroll view the items inside it should be accessible, but not the scroll view itself.




回答2:


To add more details on UIAutomation accessibility labels for UIScrollView you will have to use the index to the ScrollView to access subviews on the scroll view. Eg :

target.frontMostApp().mainWindow().scrollViews()[0].buttons()["logoutButton"].tap();

NOTE : Assumption is that the "logoutButton" is the accessibility label for the logout button and it is a subview on the scroll view.



来源:https://stackoverflow.com/questions/7685511/why-doesnt-uiscrollview-have-an-accessibility-area-in-the-interface-builder

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