Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to dynamically redraw the dragged cell as it moves up and down the table #22

Closed
robinmacharg opened this issue Feb 26, 2018 · 1 comment

Comments

@robinmacharg
Copy link

Great library, perfect drop in functionality for what I need. This is more of a feature request. I have some dynamic content - the cell number - that I'd like to have update as the cell is dragged around. Other use-cases could be imagined (background colour in an alternately-striped table etc). I'd like a method I could call from the delegate as the cell moves. I'm already reloading data in the delegate's reorderRowAt... method but this doesn't regenerate the UIImage snapshot used in dragging. A naive fix for this is to make createSnapshotViewForCell() public and call that, but I suspect that there are situations where something this simple will break. Happy to look at contributing a PR if you can suggest your preferred extension point for this. Thanks.

@adamshin
Copy link
Owner

adamshin commented Feb 27, 2018

Hey! Glad the library's been helpful for you.

Currently, the snapshot view has to be generated at the beginning of the drag-and-drop interaction. This is because the target cell isn't actually present in the tableview while the user's dragging; it's replaced with a blank 'spacer cell'. So I'm not sure if there's a simple way to accomplish what you're looking for.

Maybe you could create your own snapshot view with the same view hierarchy as the table cell, keep a reference to it in your view controller, and update it that way? You could add another TableViewReorderDelegate method, and have the reorder controller check if you're providing a custom snapshot view before it generates a UIImage snapshot. Or something like that.

If you do figure anything out, let me know. I'd welcome any contributions or improvements. The library could use a bit of work -- there's some lingering iOS 11 issues still. I've thought about a more comprehensive rewrite that relies less on UIKit behaviors... Just a matter of finding the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants