Вы можете переопределить метод экземпляра tableView (_: targetIndexPathForMoveFromRowAt: toProposedIndexPath:) в UITableViewDelegate и реализовать в соответствии с вашими потребностями. Вы можете проверить ссылку на API здесь .
Пример кода будет выглядеть следующим образом.
override func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath {
if proposedDestinationIndexPath.row == 0 {
return IndexPath(row: 1, section: proposedDestinationIndexPath.section)
} else {
return proposedDestinationIndexPath
}
}
Надеюсь, это поможет. Приветствия.!