A general strategy that I use to treat both an entire UIView as an accessibility element in addition to some of its subviews is to use the UIView's contentView as an accessibility element in place of the UIView itself. E.g.,
isAccessibilityElement = false
contentView.isAccessibilityElement = true
contentView.accessibilityLabel = "super view"
subview1.accessibilityLabel = "subview1"
subview2.accessibilityLabel = "subview2"
accessibilityElements = [contentView, subview1! subview2]
This works well most of the time, but creates issues when the view is UITableViewCell. Basically, if isAccessibilityElement = true
then when a VoiceOver user is flicking through the cells, and the lowest visible cell on screen is in focus, the tableView will autoscroll to next cell. But if the cell itself is an accessibility element, it cannot have subview which are also accessibility elements.
On the other hand, if isAccessibilityElement = false
the autoscrolling becomes erratic, often with focus jumping from the lowest visible cell to the scrollbar or accessibility elements below the tableView. It seems to depend on screen size as it autoscrolls with the focus change cleanly on some devices.
I've experimented with scrolling the tableView programmatically in response to focus changes in the cells, but this also seems to result in erratic focus jumps.
Is there anyway to ensure clean VoiceOver scrolling in a UITableView while allowing cells and subviews of those cells to be treated as accessibility elements?