UIAccessibilityContainer in child view controllers?

限于喜欢 提交于 2019-12-23 22:04:43

问题


I have a parent UIViewController to which I add four child view controllers. I’m trying to manage accessibility throughout those controllers. I have a status enum which keeps track of which of those children are visible on-screen, so when that changes, I’m updating the accessibilityElementsHidden of the children as appropriate, and sending a LayoutChanged notification.

My question relates to implementing the UIAccessibilityContainer protocol in both the parent view controller, and inside each of the child view controllers. The parent needs to know in which order those elements should be presented, etc., and each child has its own elements that also need specific ordering.

It appears that inside the children, the UIAccessibilityContainer methods (accessibilityElementCount et al), are never called, so it looks like it’s ignoring them, which leaves my elements out of order and messy.

Is this how it’s supposed to be? Could I possibly be doing something wrong here?


回答1:


Yes, that is correct, what UIAccessibilityContainer is doing is telling VoiceOver that that element is the innermost element from an accessibility perspective.

Can you give a bit more context as to what you are trying to do from a UI perspective, there might be a better way to achieve this




回答2:


The reason why your UIAccessibilityContainer methods are not being called is because they are defined as part of your view controller. They must be defined as part of your custom view to be called.

I'm just digging into UIAccessibility with my own layered view controllers so I don't have an answer to how to fix your ordering. I'll update this post if I can figure it out.



来源:https://stackoverflow.com/questions/27524569/uiaccessibilitycontainer-in-child-view-controllers

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