Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessibility collectionView focus changes when reloaded, iOS

I'm working on the accessibility of a calendar which is actually a collectionView. Whenever a cell is tapped, the collectionView will be reloaded by calling

[self.collectionView reloadData];

The problem is if the voiceOver is running, the focus will move to another place after the cell tapped because that cell is reused on somewhere else.

Is there anyway to keep the focus where it was after the reloadData? Thanks!

like image 834
Ke MA Avatar asked Feb 17 '16 16:02

Ke MA


1 Answers

Just find a workaround for this. The focus is changed because the focused cell is reused somewhere else when doing [colleciontView reloadData].

So if we reload the collectionViewCells one by one, that focused cell will not be used anywhere else. I call this method to reload the collectionView when VoiceOver is running.

- (void)reloadCalendarCollectionView {

  NSInteger items = [self.calendarItems count];

  for (NSInteger i = 0; i < items; i++) {
    [self.collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:i inSection:1] ]];
  }

}
like image 111
Ke MA Avatar answered Sep 29 '22 07:09

Ke MA