Skip to content

Instantly share code, notes, and snippets.

@dmathewwws
Created July 11, 2015 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmathewwws/37a18558426cea5edc84 to your computer and use it in GitHub Desktop.
Save dmathewwws/37a18558426cea5edc84 to your computer and use it in GitHub Desktop.
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;
}
@dataxpress
Copy link

Thanks! 👍

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