Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

voice over can only see a page of a uicollectionview

So i have a UICollectionView with a set of UICollectionViewCells displayed using a custom UILayout.

I've configured the UILayout to lay out all the UICollectionViewCells almost exactly the same as how they are laid out in the photos app on ios.

The problem is, it seems when voice over is turned on, and the user is traversing through the UICollectionViewCells using swipe, when the user gets to the last visible cell on the page, and tries to swipe forward to the next cell, it simply stops.

I know that in UITableView the cells will just keep moving forward, and the table view will scroll down automatically.

Does anyone know how to get this behaviour?

like image 733
stephen Avatar asked Nov 19 '12 05:11

stephen


1 Answers

This answer worked for me, too. Thanks!

There is one other call you must have enabled to get this to work. Otherwise your method (void)accessibilityElementDidBecomeFocused will never get called. You must enable accessibility on the object Cell.

  1. Option 1: In ViewController, set the cell instance to have accessibility.

    Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
    [cell setIsAccessibilityElement:YES];
    
  2. Option 2: Implement the accessibility interface in the cell object:

    - (BOOL)isAccessibilityElement
    {
        return YES;
    }
    
    - (NSString *)accessibilityLabel {
        return self.label.text;
    }
    
    - (UIAccessibilityTraits)accessibilityTraits {
        return UIAccessibilityTraitStaticText;  // Or some other trait that fits better
    }
    
    - (void)accessibilityElementDidBecomeFocused
    {
        UICollectionView *collectionView = (UICollectionView *)self.superview;
        [collectionView scrollToItemAtIndexPath:[collectionView indexPathForCell:self] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally|UICollectionViewScrollPositionCenteredVertically animated:NO];
        UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self);
    }
    
like image 154
Brian Cragun Avatar answered Sep 25 '22 05:09

Brian Cragun