Understanding _accessibilitySearchSubtreesAfterChildElement error in voiceover navigation

323 Views Asked by At

I have a view controller with a UITableView. The top cell in the tableView is the topmost accessibility element on the screen. On iPads, when left flicking from the top cell, behaviour is as expected: it registers the sound that there are no more elements that can get focus. Using the accessibility inspector with an iPhone simulator, again as expected navigation stops when navigating left passed the top cell and the readout of the accessibility elements in the hierarchy is as expected.

But on any real iPhone, left flicking from the top cell causes either: a) the entire view hierarchy to disappear from the screen, and focus moves to the area where the navigation bar would be or b) in some cases focus jumps to the bottom cell of the tableview.

In both cases, the following cryptic error message is delivered:

[Accessibility] |NSObjectAccessibility.m:7737 -[NSObject(AXPrivCategory)
_accessibilitySearchSubtreesAfterChildElement:direction:searchType:allowOutOfBoundsChild:range:]
|We should always have been able to find the index of the child element if we had one to begin with.

NB: navigationController?.setNavigationBarHidden is set to true. If is not, focus will move to the back button instead of the area around the nav bar, with the disappearing views (or jump to the bottom of the tableView), and the same error message.

Is anyone able to either interpret the error message, or suggest an entry point into debugging the issue?

1

There are 1 best solutions below

0
On

I had this same problem when I tried to make a UITableViewCell conform to UIAccessibilityContainer.

If you're using func index(ofAccessibilityElement element: Any) -> Int... instead of returning NSNotFound when you can't find the element like the docs tell you to, try returning the call to super, so return super.index(ofAccessibilityElement: element)

It looks like a bug on Apple's side but it does fix the issue for me.