Luke
Luke

Reputation: 9700

VoiceOver focus resetting UICollectionView to first entry?

I’m using VoiceOver, and having an issue with a UICollectionView. I have an initial screen with ten buttons, each of which links through to one of ten cells in the collection view. The collection view is actually the full size of the screen, and each cell contains a child view controller. This all works fine with VoiceOver switched off, but when it’s switched on, activating one of the buttons in the middle of the set always causes the collection view to pop to its first cell, even if I didn’t tap the first button. I think this is because the VoiceOver “focus” goes to the first element it sees (i.e. the first cell).

I’ve tried using the UIAccessibilityScreenChangedNotification and the same with Layout with an argument of the cell in question, but it’s making no difference, it’s not popping to my required element, and is always popping to the first cell in the collection.

What could I be doing wrong here?

I’m adding a snippet, this is called in viewDidLayoutSubviews, and works fine for the actual scrolling if VoiceOver is turned off. But as soon as VO is on, it breaks.

if (self.initialIndexPath) {
    [self.collectionView scrollToItemAtIndexPath:self.initialIndexPath atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, [self.collectionView cellForItemAtIndexPath:self.initialIndexPath]);
}

This works absolutely fine for actually focusing on the cell, but the VoiceOver portion is completely ignored, the notification does not shift the focus to that correct cell at all, it's always the first element in the first cell.

Also to note, the cells themselves are NOT accessibilityElements and should not be, they implement the UIAccessibilityContainer protocol, and so the title label of each cell would be where I'd like the focus to end up.

Upvotes: 44

Views: 4180

Answers (1)

Juraj Antas
Juraj Antas

Reputation: 2712

This was a bug in iOS and is fixed now.

I started to see this bug in iOS8. And reported a bug to Apple about this 6. Nov 2014. Was fixed in iOS 9.3.2.

There is nothing you can do as developer if you are on affected OS version. Recommend users of your app to update the OS.

Upvotes: 1

Related Questions