Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Accessibility in UICollectionView: VoiceOver gets stuck on last cell

I'm trying to get accessibility to work in my app. I want the exact same behavior as the "App Store" app, in the "Featured" page:

A tableview where each row contains a collectionView with some cells. I want to use VoiceOver to go thru all of the cells of a collectionView, then move to the next collectionView's cells.

The VoiceOver works when I swipe right and moves from cell to cell. The problem is that once I reach the last cell of a collectionView, instead of moving to the next collectionView, the VoiceOver gets stuck on that last cell. The app doesn't crash but stops responding.

I'm using this code in the UICollectionViewCell subclass to get the collectionView to scroll right when I reach the last visible cell:

override func accessibilityElementDidBecomeFocused() {
    let cv = self.superview as! UICollectionView
    let path = cv.indexPath(for: self)!
    if self == cv.visibleCells.last {
        cv.scrollToItem(at: path, at: .centeredHorizontally, animated: false)
        UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self)
    }
}

How can I solve this?

Thanks

like image 950
Shaked Sayag Avatar asked Nov 07 '22 23:11

Shaked Sayag


1 Answers

Maybe implement - (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction

like image 154
David Pettigrew Avatar answered Nov 14 '22 23:11

David Pettigrew