I'm locking for the solution in the method
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: UIIndexPath) {
}
After I select a Row it should change the color and move to the End of the Array, the other one should move up
I'm locking for the solution in the method
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: UIIndexPath) {
}
After I select a Row it should change the color and move to the End of the Array, the other one should move up
To move the row down, you can do:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: UIIndexPath) {
//move selected cell down to last row
tableView.moveRowAtIndexPath(indexPath, toIndexPath:NSIndexPath(forRow: tableView.numberOfRowsInSection(indexPath.section)-1, inSection: indexPath.section))
}
For changing the color see How to change color of UITableViewCell when selecting?
For data consistency you have to move the item in the table and the data source array respectively.
dataSourceArray
represents the data source array
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let itemToMove = dataSourceArray[indexPath.row]
dataSourceArray.removeAtIndex(indexPath.row)
dataSourceArray.append(itemToMove)
let destinationIndexPath = NSIndexPath(forRow: dataSourceArray.count - 1, inSection: indexPath.section)
tableView.moveRowAtIndexPath(indexPath, toIndexPath:destinationIndexPath)
}