I'm using the KIF framework and from various APIs I can fetch the UITableViewCellAccessibilityElement
for a specific UITableViewCell
subclass called RDTokenCell
.
(lldb) po element
[UITableViewCellAccessibilityElement - 0x148c9f30] <RDTokenCell: 0x14bf6db0;
baseClass = UITableViewCell; frame = (0 0; 320 50);
text = 'Fake Group 331'; autoresize = W;
layer = <CALayer: 0x14bf6f80>>) <NSIndexPath: 0x1596e2b0>
{length = 2, path = 0 - 0} - Recipient Fake Group 331
However, when I call element.accessibilityContainer
it returns the containing UITableView
and not the UITableViewCell
that the element refers to.
Why is this and how can I fetch the cell rather than the table view?
There was an additional UIView
covering the UITableViewCell
until closed by pressing an X
button in my UI. Apparently, the blocking UIView
forced the UITableViewCell
's accessibilityContainer
to the parent UITableView
.
I forced KIF
to first close the top level UIView
by instructing it to press the X
button and then all the UITableViewCell
s became accessible.
Moral of the story, if a UIView
is covering an accessibility element then the accessibility container may default to the superview of the contained element instead.