I have a toolbar , I'd like to skip the title button when accessibility is turned on.
I can skip accessibility for the whole tool bar using accessibilityElementsHidden.
but I just want to skip the accessibility focus of title bar button.
I tried disabling the title button's accessibility individually.
But it's not working.
So I set the AccessibilityElements property , it's skipping the title bar and reading out the DONE button on right side. But there's no individual focus on that DONE button at all. The focus is missing for individual bar button items when I use AccessibilityElements.
Update:
I have added an observer here
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Here is the observer
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(beginEditingHandler:) name:UITextFieldTextDidBeginEditingNotification object:nil];
Here is how I'm managing the accessibility items
- (void)beginEditingHandler:(NSNotification *)notification {
UIResponder *responder = notification.object;
IQToolbar *inputAccessoryView = responder.inputAccessoryView;
if (inputAccessoryView) {
if ([inputAccessoryView isKindOfClass:[IQToolbar class]]){
NSMutableArray *arrAccessibilityItems = [[NSMutableArray alloc]init];
if(inputAccessoryView.previousBarButton){
if(!inputAccessoryView.previousBarButton)
[arrAccessibilityItems addObject:inputAccessoryView.previousBarButton];
}
if(inputAccessoryView.nextBarButton){
if(!inputAccessoryView.nextBarButton.isHidden)
[arrAccessibilityItems addObject:inputAccessoryView.nextBarButton];
}
if(inputAccessoryView.titleBarButton){
IQTitleBarButtonItem *titleBtn= inputAccessoryView.titleBarButton;
if(titleBtn.title.length>0){
[arrAccessibilityItems addObject:inputAccessoryView.titleBarButton];
}
}
if(inputAccessoryView.doneBarButton){
[arrAccessibilityItems addObject:inputAccessoryView.nextBarButton];
}
[inputAccessoryView setAccessibilityElements:arrAccessibilityItems];
}
}
}
The problem is this read out as whole tool bar rather than a bar item by bar item.