lukescott / DraggableCollectionView

Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop. --- HELP WANTED --- Looking for maintainer and help with the experimental branch.
MIT License
549 stars 175 forks source link

How to subclass UICollectionViewLayoutAttributes and use the custom attributes in your extension? #34

Open faesa opened 10 years ago

faesa commented 10 years ago

Hi Luke, it's cool to provide such a great extension, thank you!

I successfully implemented it in my project work. In the same way I've tried to add a jiggling effect and a delete button on each cell when the longPress is fired (exactly the same behavior of iPhone's native Springboard).

To do so I've introduced a trigger (isDeletionModeActive) in viewController.m and it is positioned to YES when longPress gesture began. Then I've subclassed the 2 classes below, for 2 reasons:

But the resulting behavior isn't the one I expect as the dragging works (but not as smooth as expected during pan gesture) but the destination cell disappears when I dropped the selected cell on it.

Do you a solution so that I can subclass UICollectionViewLayoutAttributes without affect your extension logic?

Thanks a lot for your help.

faesa commented 10 years ago

Any answer? ;)

lukescott commented 10 years ago

Hi faesa,

It's hard to know what is wrong without debugging it. For the slowness, If I had to guess it probably has something to do with recalculating the layout while dragging conflicting with the animation.

I am currently working on a major project for my work, and it leaves little time for other projects. As you can see I have a bunch of unresolved issues. I do have an experimental (unfinished) rewrite I have yet to publish that may or may not resolve your issue.

I will try to take some time soon to resolve some of the outstanding issues.

faesa commented 10 years ago

Thanks a lot @lukescott, I'll wait for your future release.

roiholtzman commented 10 years ago

Hi faesa, I'm trying to build the same view you built (springboard view with the jiggling effect and draggable cells. Can you please explain how you inserted this DraggableCollectionView project into you own project? (I believe we have approximately the same Xcode project).

faesa commented 10 years ago

Hi roiholtzman, finally I didn't implement the jiggle effect because it is patented by Apple so your app will be rejected for sure if you want to use jiggle effect on cells! I've only draggable option. Sorry and good luck.

roiholtzman commented 10 years ago

Hi faesa, Thank you very much for the answer. This saved me some time.

roiholtzman commented 10 years ago

Hi faesa, I'm don't know how to use this extension with my custom layout. My layout is subclass of UICollectionViewLayout and I already override the method -(NSArray *)layoutAttributesForElementsInRect:(CGRect)rect. I'm not sure how to put their method of: