gpt4 book ai didi

ios - VoiceOver 是否总是忽略宽度和高度为零的 iOS View ?

转载 作者:行者123 更新时间:2023-12-01 21:59:03 25 4
gpt4 key购买 nike

让旁白忽略 UIL标签 将其 text 属性设置为 nil 是否足够,或者是否还需要设置 隐藏属性也为真?

我在一个示例项目中对此进行了测试,发现当文本设置为 nil 时 Voice Over 会忽略标签。我可以一直指望这个吗?在这种情况下,标签的宽度和高度为零,因为我没有添加任何约束。那么我可以假设任何宽度和高度为零的 View 都会被 Voice Over 忽略,而不管它是否隐藏?

最佳答案

In order for it [UILabel] to be ignored by VoiceOver is setting text to nil enough or should I also set the isHidden property to true as well?



合适的方式 VoiceOver 忽略的元素是 设置其 isAccessibilityElement 属性(property)给 false 👍... 其他方式取决于您正在使用的元素⟹ UILabel够了。
在这种情况下,将其文本设置为 nil 是可行的,但它更像是一个杂物,而不是一个正确的解决方案。

图形元素不应仅在 VoiceOver 运行时消失,因为 你的界面应该对每个人都一样 :例如,您可能有不识字的人可以在有或没有 VoiceOver 的情况下使用您的应用程序,如果他们在两种方式上都没有相同的视觉体验,他们可能会感到困惑。 😨

I tested this in a sample project and saw that Voice Over ignores the label when the text is set to nil. Can I always count on this?



不,你不能 因为它适用于 UILabel但是,如果您尝试对按钮或文本字段执行相同的操作,您会注意到它肯定不会起作用,因为它们的 'accessibilityTraits` .

So can I assume that any view with a width and height of zero would be ignored by Voice Over irrespective of whether it is hidden or not?



是的,您可以 因为 {width = height = zero} 意味着这个元素不是 VoiceOver 应该分析和读出的图形元素。
但是,即使它有效, 我不建议走这条路如前所述,将元素隐藏到 VoiceOver。 😉

关于ios - VoiceOver 是否总是忽略宽度和高度为零的 iOS View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60676174/

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