【发布时间】:2015-08-27 18:30:34
【问题描述】:
所以,
我正在尝试禁用已添加到 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,效果很好。但这次没有这样的运气。
谢谢!
【问题讨论】:
-
我认为栏按钮项目将提供可访问性选项,以便我可以在情节提要上禁用它,但它只显示某些元素。'
-
请让我知道我的答案是否有效。 @Kivak 狼
-
@TejaNandamuri,你找到解决方案了吗?
标签: ios objective-c accessibility uibarbuttonitem