Reputation: 54620
I have a UICollectionViewCell subclass, built in interface builder. In my test I want to tap on the first one.
The code:
- (void)tapFirstThing
{
SLElement *firstCell = [SLElement elementWithAccessibilityLabel:@"First"];
[firstCell logElement];
[firstCell tap];
}
From the inspector log:
<MYCollectionViewCell: 0x1381bc60; frame = (0 210; 320 560); id = 'First'; label = 'First'; accessibilityElement = YES>
Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().elements()["UIWindow: 0xc8652d0"].elements()["UICollectionView: 0xd8eda00"].elements()["UICollectionViewCellAccessibilityElement: 0xcf15120"]
Things I did at cell creation time in desperation that seemed to basically have no effect other than me wasting a few hours today:
if (indexPath.row == 0) {
cell.isAccessibilityElement = YES;
cell.accessibilityLabel = @"First";
cell.accessibilityIdentifier = @"First";
cell.accessibilityActivationPoint = CGPointMake(CGRectGetWidth(cell.bounds) / 2.0, CGRectGetHeight(cell.bounds) / 2.0);
}
So... how am I supposed to do this? What does that error even mean? I don't understand how I can log it, but it's UIAElementNil
?
Upvotes: 1
Views: 269