Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag and drop between two tables in ipad

Tags:

uitableview

I have two UITableView in my iPad application. I want to drag a cell from one tableview and drop onto another tableview. Please suggest me any idea how can I Implement drag & drop between two tables in iPad ?

Thanks in advance

like image 530
Deepika Avatar asked Oct 12 '10 12:10

Deepika


1 Answers

I've implemented a solution to this before.

Approach

  • The main component of the solution is class that listens for drag / drop events and broadcasts them to a delegate; I called this component the gesture coordinator. It handles the events emitted from a UIGestureRecognizer to calculate the 'drag and drop' state and notify the delegate.
  • For example, a view controller acting as its delegate would receive messages about when items have been exchanged between collections and then update its collection views and data sources.
  • The gesture coordinator is essentially just a drag-and-drop decorator for a UIGestureRecognizer.

Gesture Coordinator Logic

Here are the propositions that I considered when implementing the gesture coordinator:

  • A collection is a view that contains and array of child items.
  • A drag arena consists of a superview and an ordered set of collections that exist as subviews within that superview.
  • The order of the collections in the drag arena determines their drag / drop priority. That is, if a collection sits at the beginning of the drag arena's ordered set of collections, then drags and drops occurring on that collection will be recognized in place of any of the later collections in the set.
  • A drag starts if and only if a gesture is started within the bounds of a draggable item of a collection in the drag arena. Dragging occurs if and only if, immediately after a drag has been started, the location of the gesture changes within the drag arena.
  • A drag stops if and only if immediately after dragging the gesture stops, is cancelled or finishes.
  • A deletion occurs if and only if the drag stops at a point which is specified as being deletable. For example, the user may designate certain bounds within the drag arena to be 'delete on drop' areas.
  • A rearrange occurs if and only if the drag stops within the bounds of the collection that it started in, on a different item in that collection which is specified as being rearrangeable, and on a point in the drag arena that is not specified as being deletable.
  • A drop occurs if and only if the drag stops within the bounds of another collection in the drag arena, on a specific item or point that is specified as droppable within that collection, and on a point in the drag arena which is not specified as being deletable.

References

  • Documentation
  • Use Case examples
like image 185
sf13579 Avatar answered Oct 09 '22 02:10

sf13579