I need to set the accessibility label on my navigation bar back button. I have tried this but does not seem to take effect.
[self.navigationItem.backBarButtonItem setAccessibilityLabel:NSLocalizedString(kNavBarBackButtonAccessibilityLabel, @"")];
[self.navigationItem.backBarButtonItem setAccessibilityHint:NSLocalizedString(kNavBarBackButtonAccessibilityLabel, @"")];
[self.navigationItem.backBarButtonItem setIsAccessibilityElement:YES];
I set up my test with
+ (id) stepToGoBackToExplorations {}
I get back
FAIL (10.01s): Tap view with accessibility label "Back button"
2013-01-02 16:41:02.771 KIF Functional Testing[60766:c07] FAILING ERROR: Error Domain=KIFTest Code=0 "The step timed out after 10.00 seconds." UserInfo=0xa6494a0 {NSUnderlyingError=0xa6509a0 "Failed to find accessibility element with the label "Back button"", NSLocalizedDescription=The step timed out after 10.00 seconds.}
I have also tried this as suggested by Set the accessibility attributes on UIBarButtonItem 4
UIView *view = (UIView*)self.navigationItem.leftBarButtonItem;
[view setAccessibilityLabel:NSLocalizedString(kNavBarBackButtonAccessibilityLabel, @"")];
[view setAccessibilityHint:NSLocalizedString(kNavBarBackButtonAccessibilityLabel, @"")];
After Googling this extensively I have come up blank with how to accomplish this.
Advice would be much appreciated.
Thanks,
Joel
+ (id) stepToGoBackToExplorations {
// return [KIFTestStep stepToTapViewWithAccessibilityLabel:kNavBarBackButtonAccessibilityLabel];
return [KIFTestStep stepWithDescription:@"Select the Details text view." executionBlock: ^(KIFTestStep * step, NSError * *error) {
TITestUtility *testUtil = [TITestUtility sharedUtility];
UINavigationController * navigationController = testUtil.navigationController;
[navigationController popToRootViewControllerAnimated:YES];
return KIFTestStepResultSuccess;
}
];
}