Possible Duplicate:
How to get notified of UITableViewCell move start and end
I have implemented a UITableView with a custom design. This UITableView has to support edit mode. When entering the edit mode, UITableViewCell gets decorated with additional controls (EditControl, ReorderControl…). They don’t fit well with my custom design and that’s why I wanted to replace their images. For that purpose I subclassed UITableViewCell and overrode layoutSubview, where I replace the images for those controls.
Problem: When starting a drag & drop operation, the image for EditControl is replaced back to the original one somewhere in UITableViewCell. I can replace it again in
– tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:
when user moves the draggable cell to another indexPath, but that’s too late.
So my question boils down to: How can I detect the moment the user actually starts dragging a UITableViewCell?
While Bala’s comment went into the right direction, I initially had some problems with the right implementation. Now I found out how it can be done. In short: You have to create a custom subclass of
UITableViewCell. OverridelayoutSubviewsto attach aUILongPressGestureRecognizertoUITableViewCellReorderControl. Define a protocol and use a delegate to inform whoever you want to about the dragging state.CustomTableViewCell.h:
CustomTableViewCell.m:
Be aware that while this code doesn’t use any private APIs it still might stop working if Apple changes its internal implementation (i.e. by changing the classname of
UITableViewCellReorderControl).