Git Product home page Git Product logo

Comments (4)

wtmoose avatar wtmoose commented on June 13, 2024

Have you tried invalidating the destination layout before transitioning?

Tim

On Sep 30, 2014, at 2:19 PM, Charles Scalesse [email protected] wrote:

Hey Tim, thanks for creating this. It was working well for me when I had only one section in my collection view, but now with multiple sections I'm experiencing a crash during transitionToCollectionViewLayout:duration:easing:completion: that I wasn't experiencing with the stock setCollectionViewLayout:animated:completion: method.

The setup:
I have a collection view that supports a transition between a 1-wide grid layout and a 4-wide grid layout. The cells in the collection view are sectioned by month (Sept 2014, August 2014, ...) and the content is paginated such that when the user scrolls to the bottom new content is requested from my API and appended to my dataSource (currently just calling reloadData instead of performing any insertion updates).

Steps:

  1. Start with a 1-wide grid. Transition to a 4-wide grid. Technically there's still only 1 section at this point, because we're still in the first month of data.
  2. Scroll down a few pages in the 4-wide grid until we've reached the next section.
  3. Attempt to transition back to the 1-wide grid results in a crash at this line:

UICollectionViewLayoutAttributes *toPose = reverse
? [self.currentLayout layoutAttributesForItemAtIndexPath:indexPath]
: [self.nextLayout layoutAttributesForItemAtIndexPath:indexPath];
Because self.nextLayout's layoutAttributesForItemAtIndexPath:indexPath returns nil when the section index > 0. The error is:

Uncaught exception: *** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]

It appears that when I transition from the 1-wide layout, there's only one section in existence. Then, after scrolling the 4-wide layout, there's multiple sections. Attempting to go back to the 1-wide layout, the crash occurs.

If I scroll through many sections while in the 1-wide layout, and then scroll back up, I'm free to transition between layouts since the number of sections in the 1-wide layout is in sync with the number of sections in the 4-wide layout.

Any idea how to fix this? I'd very much like to continue using your library.

Thanks!


Reply to this email directly or view it on GitHub #13.

from tllayouttransitioning.

scalessec avatar scalessec commented on June 13, 2024

I swear that was the very first thing I tried. Honestly. Ugh.

Thanks.

from tllayouttransitioning.

wtmoose avatar wtmoose commented on June 13, 2024

Hah. Glad it worked.

Tim

On Sep 30, 2014, at 2:47 PM, Charles Scalesse [email protected] wrote:

I swear that was the very first thing I tried. Honestly. Ugh.

Thanks.


Reply to this email directly or view it on GitHub #13 (comment).

from tllayouttransitioning.

scalessec avatar scalessec commented on June 13, 2024

Just in case anyone else has this issue, I thought I'd follow up with some additional info.

There was actually 2 separate problems here resulting the same crash, hence why I thought invalidateLayout originally didn't solve the problem. The first was what is described above and is fixed by invalidating the destination layout. The second occurred when the number of sections changed during the course of the transition itself. In my case this was also pretty common, because the transition from the 1-wide grid to the 4-wide grid frequently triggers an API request for the next page, and if the response comes back before the transition completes, it'll crash with the same error.

from tllayouttransitioning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.