问题
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