gpt4 book ai didi

iOS 旁白阅读accessibilityIdentifier 而不是accessibilityLabel

转载 作者:行者123 更新时间:2023-12-01 15:24:57 68 4
gpt4 key购买 nike

VoiceOver 应该阅读 accessibilityLabel屏幕上任何辅助功能元素的属性。我有一个 UIImageViewmediaImageView ,下面的代码在此 View 上设置可访问性,并在 awakeFromNib 中调用在 UITableViewCell子类。

而不是阅读 image , VoiceOver 朗读 articleMediaCell_image这是 accessibilityIdentifier .谁能解释为什么会发生这种情况?

(在 iOS 13.3 设备上测试,无论是否设置自定义操作都会出现问题)

    mediaImageView.isAccessibilityElement = true
mediaImageView.accessibilityIdentifier = "articleMediaCell_image"
mediaImageView.accessibilityLabel = "image"

mediaImageView.accessibilityCustomActions = [
UIAccessibilityCustomAction(
name: "expand to fullscreen",
target: self,
selector: #selector(imageTapped)
)
]

最佳答案

发生这种情况是因为您已将控件类型 (UIImage) 的特征(图像)设置为 accessibilityLabel 的值。这里:

mediaImageView.accessibilityLabel = "image"
/*
Won't work, because iOS already knows that this is an image from the element's traits.
Due to this, the redundant value is ignored and the voiceover falls back to reading the `accessibilityIdentifier`.
*/
使用任何值 - “媒体”例如 - 这不是对象的特征,因为画外音将读取可访问性标签值,然后是控件类型的特征,如下所示: “媒体形象” .
mediaImageView.accessibilityLabel = "media" /* This should work */

摘自 accessibilityLabel Apple Documentation :

Note that the label never includes the control type (such as button)because the traits of the accessibility element contain thatinformation.

关于iOS 旁白阅读accessibilityIdentifier 而不是accessibilityLabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61229499/

68 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com