我试图从 VoiceOver 中隐藏应用程序中的多个元素,以便屏幕阅读器不会大声朗读它们。在 iOS 上,我将 isAccessibilityElement
设置为 NO
,但这对 OSX 没有影响。从 VoiceOver 隐藏元素的正确方法是什么?
例如,我在 View 中包含一系列标签,如果由 VoiceOver 单独说出这些标签,则这些标签毫无意义。我想在容器 View 上设置 accessibilityLabel
来描述嵌套在其中的所有标签。但如果我这样做,里面的标签仍然会被 VoiceOver 读出。
最佳答案
在 macOS 中,确实可以将 NSButton
、NSTextField
和 的
没有效果。这是因为这些是控件 - 它们继承自accessibilityElement
设置为 NO
NSImageViewNSControl
。要使其适用于控件,您必须对控件的单元格执行此操作。
在一个 Objective-C 项目中,我对几个 Cocoa 控件进行了子类化。例如,每当我希望 VoiceOver 跳过 ImageView 时,我都会在 Interface Builder 中将其自定义类设置为:
/*!
@brief Image view which will be skipped over by VoiceOver
@details Be careful that you *really* want the view to be skipped over by
VoiceOver, because its meaning is conveyed in a better, non-visual way,
elsewhere. Remember that not all VoiceOver users are completely blind.
*/
@interface SSYNoVoiceOverImageView : NSImageView {}
@end
@implementation SSYNoVoiceOverImageView
- (void)awakeFromNib {
self.cell.accessibilityElement = NO;
}
@end
关于macos - 禁用/隐藏辅助功能元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31523333/