Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to limit UITableView row reordering to a section
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;
Copy link

dataxpress commented Jul 12, 2018

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment