LoginSignup
0
1

More than 3 years have passed since last update.

Swift UITableViewの編集モードでのセル並び替え機能

Last updated at Posted at 2020-04-04

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クラスを呼び出さなくても編集モード中に並び替えだけは可能になる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1