Edward Dale
Edward Dale

Reputation: 30143

UICollectionView paging breaks after 2^24 pixels

The setup

I have a UICollectionView that allows the user to page through pictures, 12 to a page. There are upwards of 200,000 pictures that should all be available in the app. I'm not expecting a user to scroll to page 20,000, so there's function to jump to a certain page.

The problem

In landscape orientation, paging breaks down on page 16,385. The collection no longer adjusts to the page boundary. If you go back before page 16,384, you can get it to start working again, but no page past 16,385 works.

My delegate also stops getting scrollViewDidEndDecelerating: the message when the bug shows up.

The hypothesis

Page 16,385 in landscape orientation happens to start at pixel 16,777,216 which happens to be 2^24. I think that there's something in UICollectionView or UIScrollView that breaks past 2^24.

Is this just an undocumented limit? Am I out of luck?

The example

I've uploaded a project that demonstrates the problem. Here's the relevant view controller. If you shake your iPad or the simulator, you'll be taken to page 16,384, one page before the bug shows up.

The snark

If you don't think a user should need to be able to go to page 20,000, that's cool. I don't think it's relevant to the question.

Upvotes: 4

Views: 262

Answers (3)

RegularExpression
RegularExpression

Reputation: 3541

I wonder whether you've tried using multiple sections? Is the limitation per section or for the entire CV?

Upvotes: 0

Timothy Moose
Timothy Moose

Reputation: 9915

You could just load say 10,000 pages and when the user jumps, load an appropriately different 10,000 pages.

Upvotes: 0

Benjamin Mayo
Benjamin Mayo

Reputation: 6679

I'd say this is an undocumented limitation and would file a Radar bug report, attaching the sample project as evidence. If you are looking for an alternative method, you could try using a UIPageViewController with a collection view for each page. You can choose the swiping animation, rather than the default iBooks-esque animation, and replicate your sample project very closely.

Upvotes: 2

Related Questions