Skip to content

Cells lose their animation/dynamics after calling resetLayout #3

@mitchellporter

Description

@mitchellporter

I've been using the flow layout code from this tutorial for awhile now as a base for adding UIKit Dynamics to my collection views in small side projects, however I just noticed something strange now that I'm working on a more serious project.

I am using nearly identical code from the tutorial @ http://www.objc.io/issue-5/collection-views-and-uidynamics.html

I went all the way to and completed the "Adding New Rows" section but did not move on to the "Tiling your Dynamic Behaviors for Performance" section.

The only thing I'm doing differently is I'm not calling resetLayout on the flow layout right after reloading the collection view's data, otherwise for some reason I get trapped in the resetLayout method and it just keeps getting called over and over.

So now I'm just observing for value changes to the collection view's contentSize property. When this changes, then I call resetLayout on the flow layout. This works perfectly the first time it is called. However, when I scroll down far enough, I make another call to my server for more data, add the data to my data array, and reload the collection view.

The new cells are successfully added and visible, but now all of the cells lose their animation. There are no UIKit Dynamics in play anymore, and its just basic flat scrolling.

I've been playing around with this for awhile and can't seem to figure out what is going wrong.

I'm going to take some more time tomorrow to try and figure this out, and if I can't get it I'll probably just use the teehanlax flow layout that this tutorial was based off of.

I just wanted to open this issue in case anyone else has experienced this problem and has a fix and also hopefully it can help anyone else who comes across this problem in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions