UIBarButtonItem如何禁用辅助功能(IOS) [英] UIBarButtonItem How to Disable Accessibility (iOS)

查看:93
本文介绍了UIBarButtonItem如何禁用辅助功能(IOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,

我正在尝试禁用已添加到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];

我尝试了各种方法禁用画外音,但即使在当前设置中,当我点击按钮时仍显示"图例"。

我尝试过的更多方案:

这将禁用所有语音(需要),但仍允许按钮是交互式的(不需要):

[legendMenuBarItem setAccessibilityLabel:@" "]; 
[legendMenuBarItem setIsAccessibilityElement:TRUE];
[legendMenuBarItem setAccessibilityTraits:UIAccessibilityTraitNone];

这应该会禁用UIBarButtonItem及其子视图的画外音(需要),但它不会(不需要):

[legendMenuBarItem setIsAccessibilityElement:TRUE];
[legendMenuBarItem setAccessibilityElementsHidden:TRUE]; 
总而言之.我的问题是,世界上到底怎么才能完全禁用可访问的交互性呢?通常我使用setIsAccessibilityElement:FALSE,效果很好。但这次就没有这么好的运气了。

谢谢!

推荐答案

setAccessibilityElementsHidden仅当该UI元素中确实包含某些元素时才有效。

尝试setAccessibilityElementsHiddenYES工具栏或工具栏按钮所在的容器。

编辑:如果您不需要特定栏按钮的辅助功能,则需要将该按钮添加到工具栏的辅助功能元素中,该元素是NSArray,然后根据需要将其隐藏。

编辑:这将禁用导航项目的辅助功能

  self.navigationController.navigationBar.accessibilityElementsHidden=YES;

这篇关于UIBarButtonItem如何禁用辅助功能(IOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆