Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
458 views
in Technique[技术] by (71.8m points)

ipad - 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 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...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  1. Create an instance of DraggableTableViewCell and configure it to appear like the selected cell.
  2. 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.
  3. Update the data source for the source table view and remove the original cell from the table view using deleteRowsAtIndexPaths:withRowAnimation:
  4. Move the cell on the display by responding to touchesMoved:withEvent:
  5. 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
  6. Update the data source for the destination table view and call insertRowsAtIndexPaths:withRowAnimation:
  7. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...