ios - VoiceOver 未正确宣布 UITextInput

标签 ios accessibility voiceover uiaccessibility

我对 VoiceOver 播报我的自定义 UITextInput 的方式有疑问虽然它具有键盘焦点:当通过向左/向右滑动将辅助功能焦点移动到 UITextInput View 时,VoiceOver 正确宣布了 UITextInput,我听到类似 Text field, is editing, <content of text input>, character mode, insertion point at end 的声音.

但是,如果我通过点击将辅助功能焦点移动到 UITextInput,VoiceOver 会显示 empty line , 这是不正确的。

无论 UITextInput 如何获得辅助功能焦点,我都希望 VoiceOver 发出完全相同的通知。

任何想法可能是这种奇怪行为的原因?

最佳答案

要标记文本字段,您需要利用几个不同的属性。首先,“文本字段”部分只能通过让自定义控件扩展 UITextFIeld 类来获得。这是您可以在开始时获得该通知而不影响其他内容的唯一方法。您可以将其附加到标签上。以下是我为您的自定义文本编辑器推荐的属性。

首选标记

ClassType: Subclass of UITextField (Probably the most important piece)

AccessibilityLabel: The thing the entered text represents (Ex: Password, Username, etc).

AccessibilityValue: The entered text.

AccessibilityHint: "Some non critical information, that shares some details about what the entered information will be used for."

AccessibilityTraits: (NOT Static Text Trait)

请注意,提示不是关键信息。提示经常被忽略,仅包含有用的澄清信息。

替代标记(不推荐)

ClassType: Subclass of ????

AccessibilityLabel: Text field, $EditingState, $EnteredText, $InsertionPoint

AccessibilityValue: nil

AccessibilityHint: nil

AccessibilityTraits: StaticText (Weird, but if you're including role information yourself, we want the trait of static text on an editable text field, to avoid VoiceOver being smart, including it, and duplicating role information in the announcement... is this starting to feel like a hack yet???)

老实说这是一个糟糕的想法,你真的应该让你的 TextField 从系统 UITextField 继承并免费获得所有这些东西,但如果你必须,这就是你将如何实现......类似的行为而不这样做.我说相似是因为有些事情您不能在自定义控件中复制。

  • 键盘类型(“字符模式”)对你来说比系统更痛苦,我建议在自定义案例中省略。键盘不必尊重您的模式更改请求(自定义键盘等),您可能会遇到麻烦并混淆试图根据您的应用程序设置共享此内容的用户。系统是唯一可以在所有场景中做到这一点的东西。
  • 变形。通过自定义方式执行此操作,您将失去 VoiceOver 的风格和变化。标签和输入文本之间的停顿。读出占位符文本时读出的低音等。您可以在 AccessibilityLabel 中添加逗号以在某种程度上复制其中的一些内容,但最终,您的自定义控件对 VoiceOver 用户来说总是听起来有点“不对劲”。 . 除非您的自定义 View 扩展 UITextField...

关于ios - VoiceOver 未正确宣布 UITextInput,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47147747/

相关文章:

jquery - 当单击按钮时文本发生更改时,屏幕阅读器(即 JAWS)不会读取该按钮的文本?

ios - 如何获取 NSDocumentDirectory 中的目录列表?

ios - 如何从 iOS 上的 CSV 文件中每行只获取一个字段?

ios - Xcode, swift : alert not dismissing

ios - 仅适合标签的高度

vue.js - 在 Vue 2 的客户端搜索结果中无法正确读取 aria-live 区域的变化

html - 无需电子邮件地址即可访问 mailto 链接

java - 如何一次将单个数字读取为单个字符而不是字母

ios - 在 iOS 中选择时忽略辅助功能标签?

ios - 如何从 VoiceOver 中排除 UIButton?