44

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.

Luke
  • 9,512
  • 15
  • 82
  • 146
  • 1
    did you find any solution or any work around to this problem? I am too facing the same issue. – Javvadi Rajesh Dec 17 '14 at 20:37
  • It is possible that after your UIAccessibilityScreenChangedNotification, another notification is fired once the collection cell has finished being scrolled to so it'd still go to the first element. Is it your intention that once you tap on button x, that the collection view will scroll to cell x? Is cell x taking up the full width or do multiple cells fit on the screen? – micap Jan 07 '15 at 12:02
  • It's possible, but I've verified that I'm not doing it. I've turned on the accessibility inspector in the simulator and there are four or five notifications fired at that point, but I've ensured I've turned ALL of mine off, and they're still sent, so I think the system is doing it. – Luke Jan 07 '15 at 12:56
  • The cells are full-screen. The idea is that you choose a cell, it scrolls to it, and from there you can swipe left/right to move between the cells, much like the stories in the BBC News app if you've used that. – Luke Jan 07 '15 at 12:57
  • I have a layoutToLayout collectionview transition where one cell goes full screen with the behaviour you described. Once the transition is complete, the collectionview is reset to contentOffset{0, 0}, while transitioning everything is OK. Is your behaviour the same? – stefreak Jan 11 '15 at 12:47
  • If VoiceOver is turned on, yes. – Luke Jan 12 '15 at 11:25
  • Could you build a sample project that has the same issue? – Moxy Jan 12 '15 at 18:02
  • 2
    I have previously submitted a Radar for this problem (http://openradar.appspot.com/radar?id=5876737380450304) and made a sample project (https://github.com/jszumski/collection-view-voice-over-focus). – jszumski Aug 16 '15 at 14:49
  • I had similar experience in May 2016, with iOS8, (where voiceover had so many bugs it was really ugly), and it was resolved in iOS 9.3.2. Now I can confirm it works fine with iOS11.2.6. What is the iOS version were you have this issues? – Juraj Antas Mar 21 '18 at 12:02

1 Answers1

1

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.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Juraj Antas
  • 3,059
  • 27
  • 37