禁用/隐藏辅助功能元素 [英] Disable / hide accessibility element

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

问题描述

我试图从 VoiceOver 隐藏我的应用程序中的几个元素,以便屏幕阅读器不会大声朗读它们.在iOS上,我将 isAccessibilityElement 设置为 NO ,但这对OSX没有影响.从VoiceOver隐藏元素的正确方法是什么?

I'm trying to hide several elements in my app from VoiceOver so that they don't get read aloud by the screen reader. On iOS, I'd set isAccessibilityElement to NO, but this has no effect on OSX. What's the correct way to go about hiding elements from VoiceOver?

例如,我在视图中包含一系列标签,如果它们由VoiceOver单独说出,则毫无意义.我想在容器视图上设置 accessibilityLabel 来描述嵌套在其中的所有标签.但是,如果这样做,VoiceOver仍会读出其中的标签.

For example, I have a series of labels contained inside a view that make no sense if they're spoken separately by VoiceOver. I'd like to set the accessibilityLabel on the container view to describe all the labels nested within. But if I do that, the labels inside are still read out by VoiceOver.

推荐答案

在macOS中,确实可以将 NSButton accessibilityElement 设置为 NO >, NSTextField NSImageView 无效.这是因为它们是控件 –它们是从 NSControl 继承的.为了使其适用于控件,您必须改为对控件的 单元格 进行操作.

In macOS, it is true that setting accessibilityElement to NO for NSButton, NSTextField and NSImageView has no effect. That is because these are controls – they inherit from NSControl. To make it work for controls, you must do it instead to the control's cell.

在Objective-C项目中,我将几个可可控件归为一类.例如,每当我希望VoiceOver跳过图像视图时,便在Interface Builder中将其自定义类"设置为此:

In an Objective-C project, I so subclassed several Cocoa controls. For example, whenever I want a image view to be skipped by VoiceOver, I set its Custom Class in Interface Builder to this:

/*!
 @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

这篇关于禁用/隐藏辅助功能元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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