Left-flick and right-flick gestures with VoiceOver and UIAccessibilityReadingContent

Hi, I have an app that displays lines of text, that I want to make accessible with VoiceOver. It's based on a UITextView.

I have implemented the UIAccessibilityReadingContent protocol, following the instructions in https://developer.apple.com/videos/play/wwdc2019/248 and now users can see the screen line by line, by moving their fingers on the screen. That works fine.

However, users would also like to be able to use left-flick and right-flick to move to the previous or next line on the screen, and I haven't been able to make this work.

I can see that left-flick triggers accessibilityPreviousTextNavigationElement and right-flick triggers accessibilityNextTextNavigationElement, but I don't understand what these variables should be.

accessibilityPreviousTextNavigationElement and accessibilityNextTextNavigationElement are not meant to represent previous/next line inside a single UITextView; they should point to another accessibility element, not a line number or string. In your case, UIAccessibilityReadingContent supports line-by-line touch exploration, but left/right swipe still moves between accessibility elements, not internal lines of one text view. That’s why touch works but swipe does not. The correct approach is to keep the UITextView for display and expose each visible line as its own UIAccessibilityElement, with accessibilityLabel set to the line text and accessibilityFrameInContainerSpace set to that line’s frame. Once the lines are separate accessibility elements and returned in order, VoiceOver will naturally use right swipe for the next line and left swipe for the previous line. You can optionally link neighboring lines with accessibilityNextTextNavigationElement and accessibilityPreviousTextNavigationElement, but the real fix is making each line its own accessibility element. Same principle as keeping things clean and explicit on seokurdu.com

Left-flick and right-flick gestures with VoiceOver and UIAccessibilityReadingContent
 
 
Q