TeehanLax / UICollectionView-Spring-Demo

A demonstration of UICollectionView and UIKit Dynamics
MIT License
472 stars 71 forks source link

crash on [self.dynamicAnimator addBehavior:springBehaviour]; #21

Open bukira opened 8 years ago

bukira commented 8 years ago

I get the following crash on the about line

* Assertion failure in -[UIDynamicAnimator _registerBodyForItem:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3505.17/UIDynamicAnimator.m:872 * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid size {0, 0} for item <UICollectionViewLayoutAttributes: 0x159b7cb0> index path: (<NSIndexPath: 0x158fa0a0> {length = 2, path = 0 - 6}); frame = (0 0; 0 0); in Dynamics'

x401om commented 8 years ago

If you are trying to change layout when view with UIDynamicAnimator isn't on screen (e.g. modal controller is opened), you'll get this crash.

juliengdt commented 8 years ago

Problem: If you are trying to insert/delete cell that are not on screen, you will get a exception on frame/indexPath stuff.

Solution: Delete override for method prepareForCollectionViewUpdates. Nothing to do in it. Relica for another Spring animation (for falling animation on deletion)

if you want a bit cleaner: https://gist.github.com/juliengdt/df69cf601277216008319013bc87269a

@ashfurrow you can modify your implementation by using my gist if you want. no prob

ashfurrow commented 8 years ago

Yup, would love to but I'm not in the T+L organization anymore, so I'm afraid I can't.