所以,
我正在尝试禁用添加到UINavigationController的leftBarButtonItems中的UIBarButtonItem的VoiceOver可访问性。虽然我可以为没有标题的按钮禁用它,但似乎无法为具有标题的按钮禁用它。例如:
// Create the legend UIBarButtonItem
UIBarButtonItem *legendMenuBarItem = [[UIBarButtonItem alloc] initWithTitle:@"Legend" style:UIBarButtonItemStylePlain target:tool action:@selector(activate)];
// Should disable accessibility on the button, still enabled for subviews
[legendMenuBarItem setIsAccessibilityElement:FALSE];
// Remove "button" from VoiceOver speech for the button
[legendMenuBarItem setAccessibilityTraits:UIAccessibilityTraitNone];
// Removed "Legend" from being spoken, but the button is still tappable in accessibility mode
[legendMenuBarItem setAccessibilityLabel:@" "];
// Attempt to remove any accessibility elements... no real effect
[legendMenuBarItem setAccessibilityElements:nil];
// Supposedly this should disable all subviews from being accessible? Doesn't work...
[legendMenuBarItem setAccessibilityElementsHidden:TRUE];
// Add legend UIBarButtonItem to the end of the leftBarButtonItems
NSMutableArray *currentLeftBarItems = [NSMutableArray arrayWithArray:[self.navigationItem leftBarButtonItems]];
[currentLeftBarItems addObject:legendMenuBarItem];
[self.navigationItem setLeftBarButtonItems:currentLeftBarItems];
我尝试了多种方法来禁用VoiceOver,但即使在当前设置下,当我点击按钮时它仍会读出“Legend”。
更多我尝试过的场景:
这可以禁用所有语音(所需),但仍允许按钮交互(不希望):
[legendMenuBarItem setAccessibilityLabel:@" "];
[legendMenuBarItem setIsAccessibilityElement:TRUE];
[legendMenuBarItem setAccessibilityTraits:UIAccessibilityTraitNone];
这个操作应该可以禁用UIBarButtonItem及其子视图的VoiceOver(期望的),但实际上没有成功(不期望的):
[legendMenuBarItem setIsAccessibilityElement:TRUE];
[legendMenuBarItem setAccessibilityElementsHidden:TRUE];
总之...我的问题是如何完全禁用可访问性交互?通常我使用
setIsAccessibilityElement:FALSE
,这很有效。但这次没有这样的好运。谢谢!