配音只能看到一个uicollectionview的页面

所以我有一个UICollectionView,其中包含一组使用自定义UILayout显示的UICollectionViewCells。

我已经将UILayout配置为布局所有UICollectionViewCells几乎与它们在ios上的照片应用程序中的布局方式完全相同。

问题是,当打开语音时,用户正在使用滑动遍历UICollectionViewCells,当用户到达页面上的最后一个可见单元格并尝试向前滑动到下一个单元格时,它就会停止。

我知道在UITableView中,单元格将继续向前移动,表格视图将自动向下滚动。

有谁知道如何获得这种行为?

这个答案对我也有用。 谢谢!

您必须启用另一个调用才能使其正常工作。 否则,您的方法(void)accessibilityElementDidBecomeFocused永远不会被调用。 您必须在对象Cell上启用辅助function。

  1. 选项1:在ViewController中,将单元实例设置为具有辅助function。

    Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath]; [cell setIsAccessibilityElement:YES]; 
  2. 选项2:在单元对象中实现辅助function界面:

     - (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); } 

经过几个小时的头痛,解决方案非常简单。 如果有其他人遇到类似的问题,这就是我做的:

在您用于CollectionView的UICollectionViewCell的子类中,覆盖accessibilityElementDidBecomeFocused并实现它,如下所示:

 - (void)accessibilityElementDidBecomeFocused { UICollectionView *collectionView = (UICollectionView *)self.superview; [collectionView scrollToItemAtIndexPath:[collectionView indexPathForCell:self] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally|UICollectionViewScrollPositionCenteredVertically animated:NO]; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil); } 

斯蒂芬的回答对我有用! 谢谢。

我想补充一点,这似乎只影响iOS6; 看起来他们在iOS7中修复了它。

此外,您可以通过将self而不是nil传递给UIAccessibilityPostNotification来使滚动更快更干净 – 就像这样:

 - (void)accessibilityElementDidBecomeFocused { UICollectionView *collectionView = (UICollectionView *)self.superview; [collectionView scrollToItemAtIndexPath:[collectionView indexPathForCell:self] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally|UICollectionViewScrollPositionCenteredVertically animated:NO]; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self); }