Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Voiceover decide what cell to focus for UITableView?

I have a tableview that's set to load more items when scrolled near the bottom and I'm trying to make it accessible.

However when swiping to focus the tableView, the voiceover cursor always focuses the last cell even if it's really far from the current view which causes more cells to be loaded.

To avoid that, is there any way to force voiceover to focus on visible cells only? The default messages app on iOS seems to do this.

like image 444
user3211122 Avatar asked Sep 08 '16 23:09

user3211122


1 Answers

When the view gets updated with new cells, you can post layoutChanged notification from UIAccessibility indicating which element VoiceOver should focus.

UIAccessibility.post(notification:.layoutChanged, argument:elementToBeFocussed)

Read more information from the documentation.

UIAccessibility.post: https://developer.apple.com/documentation/uikit/uiaccessibility/1615194-post

UIAccessibility.Notification: https://developer.apple.com/documentation/uikit/uiaccessibility/notification

layoutChanged: https://developer.apple.com/documentation/uikit/uiaccessibility/notification/1620186-layoutchanged

like image 145
jl303 Avatar answered Sep 18 '22 12:09

jl303