Created
May 31, 2020 05:59
-
-
Save aqubi/13012c3eacc9804b2524decbf70f6f2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { | |
return true | |
} | |
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { | |
if sourceIndexPath.section != destinationIndexPath.section { return } | |
SURDataManager.shared.move(from: sourceIndexPath, to: destinationIndexPath) | |
} | |
func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath { | |
if sourceIndexPath.section != proposedDestinationIndexPath.section { | |
var row:Int = 0 | |
if sourceIndexPath.section < proposedDestinationIndexPath.section { | |
row = tableView.numberOfRows(inSection: sourceIndexPath.section) - 1 | |
} | |
return IndexPath(row: row, section: sourceIndexPath.section) | |
} | |
return proposedDestinationIndexPath | |
} | |
//MARK:- UITableViewDragDelegate implements | |
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] { | |
return [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment