voice over can only see a page of a uicollectionview

前端 未结 4 419
忘了有多久
忘了有多久 2020-12-13 21:26

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 UICollectionView

4条回答
  •  鱼传尺愫
    2020-12-13 22:06

    After hours and hours of headache, the solution was really simple. If anyone else comes across a similar problem, this is what i did:

    In the subclass of UICollectionViewCell that you are using for your CollectionView, override accessibilityElementDidBecomeFocused and implement it like this:

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

提交回复
热议问题