Asymptotik Drag and Drop

Drag Source and Drop Zones by either subclassing or wrapping UIView and subclasses

Drag shadow generation for UIView

UIScrollView drag target auto scrolling

AtkDragAndDropManager uses the delegate pattern to allow a wide varienty of drag and drop scenarios

Accepts any continuous UIGestureRecognizer class for drag recognition

Works with the UIPasteboard as a means of data passing for the drag and drop operation.

Complete set of lifecycle handlers.

The current limitation to the library is that drag and drop takes place for objects that are associated with a common root view. In practice this simply limits draging across UIWindows. This library does not currently use ARC. I know. I know. But my motivation was a much bigger project that has not yet been converted.

I wrote this because I needed drag and drop support and didn't find something out there that met all my needs. Please try it out and give me your feedback. I'm interested in making this pretty robust and will accept reasonable pull requests. If you want to do big changes, I'm open, but lets talk.

Example

The source base provides a few examples that use most of the features. Here is a simple example of setting up a scenario that uses most of the defaults.

Here we have a UIView drag source.

@interfaceAtkSampleOneDragSourceView<AtkDragSourceProtocol>
@end@implementationAtkSampleOneDragSourceView
- (BOOL)shouldDragStart:(AtkDragAndDropManager *)manager
{
returnYES;
}
- (void)dragWillStart:(AtkDragAndDropManager *)manager
{
// This is called before any call to AtkDropZoneProtocol shouldDragStart. // It's a good place to setup data for that method to examine.
manager.pasteboard.string = [NSStringstringWithFormat:@"val-%ld", (long)self.tag];
}
@end

Updates

0.2.1 -> 0.2.2

dragStarted lifecycle event is not called on DropZones that return YES to shouldDragStart.

Cleaned up examples.

0.2.0 -> 0.2.1

Fixed an issue in Sample 2 which caused a crash. This code was left in after the refactor from 0.1.0 -> 0.2.0 by mistake.

0.1.0 -> 0.2.0

added drag and drop handler methods to the AtkDragAndDropManagerDelegate.

added shouldDragStart to AtkDragSourceProtocol and AtkDropZoneProtocol. dragStarted no londer returns a boolean.

made all protocol methods optional. this allows for maximal flexability.

if a AtkDragAndDropManagerDelegate does not implement methods findDragSource: findDropZones: or isDropZoneActive:recognizer: we look to the AtkDefaultDragAndDropManagerDelegate.

added dragWillStart to AtkDragSourceProtocol. this is called before dragStarted and AtkDropZoneProtocol shouldDragStart and allows us to setup data for drop zones to look at in shouldDragStart so they can determine if they want to participate as a drop zone.