The top level container view is a custom UICollectionView. I have added two custom container views on top up location. The hierarchy tree is like below
custom UICollectionView
|- custom UIView container => 1 ImageButton
|- custom UIView container => 8 Buttons
|- custom UICollectionCells
Voice Over could respond with these buttons correctly.
But when I tried to use UIAutomation
with target.logElementTree()
, the element tree only finds the UICollectioncell list under the cutom UICollectionView, It cannot find the custom subview container and their children.
Then I tried Xcode UI Testing, using app.debugDescription
. The result still only contains UICollectionCells in the custom UICollectionView, without buttons.
How could I make them appear in the UIAutomation element tree?
Finally by using Aspects with the custom collection category:
In custom collection category, override +(void)load
:
a
, which storing all accessibilityElements
after execution initWithFrame:collectionViewLayout:
or initWithCoder:
a
after execution addSubview:
finally, implement UIAccessibilityContainer protocol methods using the property a
Tricky part:
use objc_setAssociatedObject
and objc_getAssociatedObject
to handle a