'CollectionView Cell inside UITableView is not scrolling horizontally for Voice Over accessibility
In my app, I have a screen where I need to support voice over accessibility. The screen has a TableView and inside that a collectionView. When voice over is ON and when I try to single or three fingers swipe, the collectionView scroll is not working. The accessibility focus is not moving to the next cell. Voice over is working fine only for visible cells in collectionView.
I tried by disabling accessibility for collectionView Cell and UITableViewCell but still, it didn't work.
I want to make it work like in the AppStore, where we will have a similar kind of design.
I am attaching screenshots of my screen and some codes.
Solution 1:[1]
On your country cell on awakeFromNib function or your init function depends how you initialize the cell add the line self.contentView.isUserInteractionEnabled = false
after super call.
Solution 2:[2]
The purpose of your screen isn't really clear to me but I can suggest an interesting way to use collection views with VoiceOver:
- Define a
UIAccessibilityElement
to be inserted as a carousel element (element of your collection view). - Set its trait to
.adjustable
in order to select the different elements by swiping right or left. - Adapt the label and the value according to the selected cell.
- Define the collection view [accessibilityElements].
It may be tedious ? but that's what Apple's engineers recommend ? a complete and detailed example is introduced in a WWDC session, don't hesitate to take a look at it to perfectly implement your collection view for the VoiceOver users. ?
Solution 3:[3]
what you need is just to say to tableview cell that your collection is accessible doing something like this:
accessibilityElements = [collectionView]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Vasilis D. |
Solution 2 | |
Solution 3 | Alcides Junior |