3

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?

Luke
  • 9,512
  • 15
  • 82
  • 146

2 Answers2

1

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.

Dan Loughney
  • 4,647
  • 3
  • 25
  • 40
0

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

unobf
  • 7,158
  • 1
  • 23
  • 36
  • I have a `containerViewController` which basically manages the four children. They sometimes show or hide, and this container VC manages that behaviour. Some of the child VCs are off-screen at certain times, and so I don't want accessibility picking them up at those moments. However, I need to specify the order of both those VCs, and the elements INSIDE those VCs. That's the tricky part :( – Luke Dec 18 '14 at 13:15
  • Yes, that’s what I’m using to show and hide the VCs. The issue is that the container protocol methods in the child VCs are never called, and so the order of their elements is messed up. – Luke Dec 18 '14 at 13:59
  • You do not need to implement UIAccessibilityContainer at all, just set accessibilityElementsHidden appropriately – unobf Dec 19 '14 at 02:22
  • Yes, I DO need to implement it, I need to set the order of the elements inside each child! There’s no other way to do that (that will work with both iOS7 and iOS8) – Luke Dec 19 '14 at 08:33
  • UIAccessibilityContainer is not going to work for your scenario. If the "order" is being determined by what is visible, then accessibilityElementsHidden will ensure that only the visible things will be exposed to the AT. If there is more to your "order" problem, then please provide more info and I could possibly make some suggestions – unobf Dec 19 '14 at 14:05