canMoveRowAtを呼び、trueにする。
sample.swift
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
return true
}
moveRowAtクラスに並び替えの細かい操作を記入する。
sample.swift
override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
//並び替え中に他に行いたい操作を書く(データの保存など)
}
上の2つのクラスどちらも呼び出さないと並び替えをすることは可能にならない。
canEditRowクラスを呼び出さなくても編集モード中に並び替えだけは可能になる。