A DroppableView
represents a single draggable View. You may use it as a base class for the views, that you need to be draggable in your project. Currently it is built, to be used within a scrollView. But this could easily be changed.
The demo app demonstrates, how the DroppableView
may be used in a project.
The DroppableView
is used as a subview of a UIScrollView
and can be dragged within and also out of the scrollview.
Initalize the DroppableView like in th following example:
aScrollView
is the parent scrollViewtarget
is a view outside of the scrollview, to where the element should be dragged.
- (id) initWithScrollView: (UIScrollView *) aScrollView andDropTarget: (UIView *) target;
and add it as a subview to your UIScrollView
.
Note: Your UIScrollView
needs to set canCancelContentTouches = NO;
.
The black cards can be dragged from the red scrollView onto the green circle.
Try it!