SwiftReorder icon indicating copy to clipboard operation
SwiftReorder copied to clipboard

two tableview problem

Open koust opened this issue 4 years ago • 6 comments

Hi,

I have two tableviews in the vc. I can move from row 1 to row 0 in my first tableview but if I want to move from row 1 to row 0 in my second tableview, it doesn't work.

Can u help me about this problem?

koust avatar Jun 05 '20 06:06 koust

This library only allows dragging cells within a single tableview. If you need to drag cells between multiple table views, you should use the new iOS drag-and-drop apis.

adamshin avatar Jun 05 '20 23:06 adamshin

Actually, I asked a different question. I don't wanna use to drag cells between multiple table views. I use as a single each tableviews. Only I have two table views. I drag from row (1,2,3,4,5) to row 0 on my first tableview and it's working. but the second tableview is not working if I drag from (1,2,3,4,5) to row 0.

I attached a video about the problem.

https://youtu.be/cs_FxzoW-Io

koust avatar Jun 07 '20 19:06 koust

I see, I misread your question. Do you have the same view controller as the reorder delegate for both tableviews? It looks like that might be the issue.

adamshin avatar Jun 08 '20 06:06 adamshin

I added reorder delegate for both tableviews on the same view controller. I mean yes

koust avatar Jun 08 '20 06:06 koust

In your TableViewReorderDelegate methods, are you checking which tableview is being interacted with before updating your data model? Like this:

extension MyViewController: TableViewReorderDelegate {
    func tableView(_ tableView: UITableView,
        reorderRowAt sourceIndexPath: IndexPath,
        to destinationIndexPath: IndexPath) {
        
        if tableView == firstTableView {
            // Update first data model
        } else if tableView == secondTableView {
            // Update second data model
        }
    }
}

adamshin avatar Jun 09 '20 16:06 adamshin

Exactly, like this. If drag cells from row (1,2,3,...) to 0, this fuction doesnt work. but it work from row 0 to 1 or row 2 to 3 etc.

koust avatar Jun 10 '20 06:06 koust