Joey Joey - 7 months ago 42
iOS Question

Prevent VoiceOver from navigating other pages of UICollectionView

I have a paging

that allows the user to swipe through the collection view cells horizontally. It does have two pages but at times I want to disable that so that users cannot navigate past the first page.

I am currently setting the page control's
scrollEnabled = false
on the
, and this does stop the user from 3-finger swiping to go to the other page, but it doesn't prevent accessing that page using other methods. If they tap the button that comes after the collection view then they swipe left to go to the previous element, it focuses on the last cell on the second page of the collection view.

I then tried also setting
pagingEnabled = false
, but then if the user highlights the last cell in the first row then swipes right, then it will scroll over so you can see half of the first page and half of the second page and it highlights the first character of that second page.

How can I prevent VoiceOver from navigating to the second page of the collection view?


I wasn't able to find a solution to prevent VoiceOver from navigating to other pages, but I was able to address the cause of the problem which is a better solution.

In collectionView:numberOfItemsInSection: check to see if there should only be one page and if so then run an algorithm to calculate the max number of cells that should be displayed in that single page, then perform the original calculation for the number of cells, and finally return the min of those two values. This will ensure only the cells that will be visible are created, therefore there will not be an extra page, and this will improve performance as well.