gpt4 book ai didi

ios - 使用 `accessibilityLabel` 和 `accessibilityHint` 在 iOS 中正确实现 VoiceOver 辅助功能

转载 作者:搜寻专家 更新时间:2023-11-01 07:10:20 24 4
gpt4 key购买 nike

我正在尝试优化我的应用程序。使用 accessibilityLabelaccessibilityHint 在 iOS 中实现辅助功能的最佳实践方法是什么?是否始终需要无障碍标签?

我的应用程序非常动态, View 中的对象会根据用户的操作频繁更新。例如,一个 View 可能以一种形状开始,然后变成另一种形状。因此,每个对象的 accessibilityLabelaccessibilityHint 会经常更新,以反射(reflect)打开 VoiceOver 的用户的更改 View 。


Questions

  1. Is it safe to expect that when VoiceOver is not running (i.e. !UIAccessibilityIsVoiceOverRunning()) then setting accessibilityLabel and accessibilityHint is completely unnecessary?

  2. Are there assistive technologies other than VoiceOver that a user might use that access accessibilityLabel and accessibilityHint?

最佳答案

What is the best practice method for implementing accessibility in iOS with accessibilityLabel and accessibilityHint?

您应该考虑覆盖属性实现,而不是“设置”可访问性标签。允许需要可访问性标签的 View 在需要时计算其值,而不是始终保持值同步。容易多了!您可以使用如下所示的代码来执行此操作。

override public var accessibilityLabel: String? {
get {
return "Calculated label"
}
set {
//Specifically do nothing. We're not "setting a property" we're responding to changes of the internal views.
}
}

Are accessibility labels always required?

是也不是。对于呈现信息和可单独聚焦的元素,始终需要辅助功能标签(您可能有一组 f 控件,包裹在一个布局中,带有一个辅助功能标签)。我可以相当肯定地说,在您问题的上下文中,删除可访问性标签绝对是不正确的做法。

Is it safe to expect that when VoiceOver is not running (i.e. !UIAccessibilityIsVoiceOverRunning()) then setting accessibilityLabel and accessibilityHint is completely unnecessary?

不,辅助功能属性在 VoiceOver 之外还有其他用途。

Are there assistive technologies other than VoiceOver that a user might use that access accessibilityLabel and accessibilityHint?

在 VoiceOver 之外当然还有辅助技术,它们依赖于无数的辅助功能属性。 (盲文板、开关访问等)

Conclusion

在我看来,您似乎正试图将可访问性作为一种软件实践来解决,并使这样做合理化。这是错误的思维过程。但是,由于某些基本的设计问题,使您可以访问的 View 可能确实不切实际。你应该考虑你所拥有的东西是否是以一种可以从开发/API 的角度访问的方式设计的。 API 确实会限制您完成某些事情。您是否遇到这些限制之一不是您可以在 StackOverflow 上提出的问题,解决方案是不要忽略可访问性信息。它是重新设计控件,或者可能提供替代的可访问实现……尽管应该非常仔细地考虑这条路线。一般来说分开是不相等的。

关于ios - 使用 `accessibilityLabel` 和 `accessibilityHint` 在 iOS 中正确实现 VoiceOver 辅助功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45357365/

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