Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My solution was to use a custom <code>UIGestureRecognizer</code> for tracking the touch events, and a separate view for drawing the dragging operation. </p> <p>This works because <code>UIGestureRecognizer</code> doesn't block the responder chain. From the <code>UIGestureRecognizer</code> documentation:</p> <blockquote> <p>UIGestureRecognizer objects are not in the responder chain, yet observe touches hit-tested to their view and their view's subviews. </p> </blockquote> <p>Create a custom <code>UIViewController</code> (DragAndDropViewController) and add its view to the parent view of the views you want the drag &amp; drop operation to occur in. Use your custom gesture recognizer class to forward the touch information to your DragAndDropViewController.</p> <p>The source tells your DragAndDropViewController where the the drag originates from (and any custom info). The controller should also have a delegate reference to the drop destination. When the drop occurs, send the delegate the UITouch event (not recommended according to Apple, but the UITouch object is needed to get the correct location in the destination view).</p> <p>This is what my DragAndDropViewController looks like:</p> <p><pre><code>@protocol DragAndDropDestination</p> <ul> <li>(void)droppedItem:(NSDictionary *)item withTouch:(UITouch *)touch;</li> </ul> <p>@end</p> <p>@interface DragAndDropViewController : UIViewController { id _dropDestination; NSDictionary *_draggedItem; UIImageView *_icon; }</p> <p>@property (nonatomic, assign) id dropDestination; @property (nonatomic, retain) NSDictionary *draggedItem;</p> <p>// Source sends this message - (void)startDraggingWithItem:(NSDictionary *)item;</p> <p>@end</pre></code></p> <p>Once the destination gets the message, you can use <code>- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event</code> to get the exact view at the drop destination.</p> <p>Also make sure you disable <code>cancelsTouchesInView</code> in the gesture recognizer if you want other UI operations to happen normally in your table views.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload