I have a button inside of a UITableView. The UITableView was created in storyboard, but the button was created pragmatically. I get:
Unexpected exception occurred SLUIAElementInvalidException for reason: Element '<SLButton description:"Add Memberin">' does not exist.
when I try to "tap" the button element:
SLButton *addMemberButton = [SLButton elementWithAccessibilityLabel:@"Add Member"];
SLLog(@"%@", addMemberButton); // prints <SLButton description:"Add Member">
[addMemberButton tap];
I have the following code in viewDidLoad in the viewController:
- (void)viewDidLoad {
[super viewDidLoad];
self.addMemberButton.isAccessibilityElement = YES;
self.addMemberButton.accessibilityValue = @"Add Member";
self.addMemberButton.accessibilityTraits = UIAccessibilityTraitButton;
}
When I use the accessibility inspector, the button is accessible and has the label I created. I even tried turning off accessibility in the UITableView with:
self.tableView.isAccessibilityElement = NO;
self.tableView.accessibilityLabel = nil;
This made no difference. Any insights as to how to fix this would be greatly appreciated.