How move/reorder cells from TableView1 to TableView2
I have several UITableViews, with different datasources in a iPad screen.
I need to copy/move a cell from the first tableView to the second, similar how is done with ListBox in other languages.
Now, I can reorder the cells, but the movement is restricted to the tableView. I want to drag the cell in tableView1 & drop in tableView2.
P.D. I'm open to use any other control to archive this. I take a look at AQGridView & DTGridView, however the layout is based in columns开发者_Python百科 with different #items. If I can emulate columns with this controls or other then I can accept the workaround.
UPDATE:
I hope this links could help:
Observing pinch multi-touch gestures in a UITableView
This is the most close answer:
Drag and drop between two tables in ipad
I know how get a image from a view, I can detect the drag with a Gesture Recognizers, so I have all the setup in place but have not expertise in graphic development, so don't know how put this in motion...
This is definitely a very interesting question, and I wish I had the time to put together some test code to see if the idea I'm about to outline would actually work. My hope is that this will at least point you in the right direction.
UITableViewCell is a subclass of UIView, so I would create a subclass of UITableViewCell called something like DraggableTableViewCell so we can handle the touch events and then perform the following steps:
- Create an instance of DraggableTableViewCell and configure it to appear like the selected cell.
- Add the new cell as a subview of a view that is a common superview to both tables at the same location as the original cell.
- Update the data source for the source table view and remove the original cell from the table view using
deleteRowsAtIndexPaths:withRowAnimation:
- Move the cell on the display by responding to
touchesMoved:withEvent:
- When
touchesEnded:withEvent:
is received, verify the cell is somewhat close to the other table view and determine the index path where to insert the new cell - Update the data source for the destination table view and call
insertRowsAtIndexPaths:withRowAnimation:
- Remove your draggable cell from its superview with a nice animation.
This entire process will need to be orchestrated by the view controller that controls the various table views on the screen.
精彩评论