Created
July 11, 2015 21:20
-
-
Save dmathewwws/37a18558426cea5edc84 to your computer and use it in GitHub Desktop.
How to limit UITableView row reordering to a section
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
override func tableView(tableView: UITableView, targetIndexPathForMoveFromRowAtIndexPath sourceIndexPath: NSIndexPath, toProposedIndexPath proposedDestinationIndexPath: NSIndexPath) -> NSIndexPath { | |
if sourceIndexPath.section != proposedDestinationIndexPath.section { | |
var row = 0 | |
if sourceIndexPath.section < proposedDestinationIndexPath.section { | |
row = tableView.numberOfRowsInSection(sourceIndexPath.section) - 1 | |
} | |
return NSIndexPath(forItem: row, inSection: sourceIndexPath.section) | |
} | |
return proposedDestinationIndexPath; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! 👍