UITextView with voiceover

时光毁灭记忆、已成空白 提交于 2021-02-07 11:20:17

问题


Here is my very simple code for creating a UITextView.

UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds];
textView.editable = NO;
textView.text = @"Using iOS 3.0 and later, VoiceOver is available to help users with visual impairments use their iOS-based devices. The UI Accessibility programming interface, introduced in iOS 3.0, helps developers make their applications accessible to VoiceOver users. Briefly, VoiceOver describes an application’s user interface and helps users navigate through the application’s views and controls, using speech and sound. Users familiar with VoiceOver in Mac OS X can leverage their experience to help them quickly come up to speed using VoiceOver on their devices.";
[self.view addSubview:textView];

Given that I could not possibly do anything wrong here I am just wondering if this is an expected behaviour or a bug perhaps somebody also faced:

With voiceover enabled I expect the entire text view to be “highlighted” on tap, then its accessibilityLabel to be read to a user and after they double tap, the entire text view’s text to be read.

But what is happening is that a small portion of the text view is highlighted (usually 2 lines), accessibilityLabel is not read, but the first “highlighted" line and the first letter (!) of the second line are read instead and only after a user double taps the entire text is read.

enter image description here

Especially reading the first letter in the second highlighted line confuses me. Plus shouldn’t accessibilityLabel be always read in the beginning? This looks like a big to me but Apple has always paid so much attention to accessibility, so I’m having doubts if I should report it, may be the meant it to be this way.

Another question: is there a way to achieve the following behaviour (without subleasing UITextView) when voiceover is enabled: user taps UITextView -> accessibilityLabel and the entire text are read?


回答1:


In case someone else has this problem here is the answer:

textView.accessibilityTraits = UIAccessibilityTraitStaticText;



回答2:


textView.isAccessibilityElement = true

This Works



来源:https://stackoverflow.com/questions/26204842/uitextview-with-voiceover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!