I am trying to change the order of a particular group of cells in a particular section of UITableView with static content. I am trying to do this before the view loads, but for some reason I cannot get it to work.
I have tried creating reference outlets for each of the cells and then calling tableView.moveRow by calling in tableView.indexPath(for: cell1
I have also tried giving each a tag and looping through the cells in that section and reordering with with no success.
I have tried:
// Moving the row from it's default row
self.tableView.moveRow(at: IndexPath(row: 1, section: 1), to: IndexPath(row: newRow, section: 1))
// Creating a reference outlet called cell1
self.tableView.moveRow(at: self.tableView.indexPath(for: cell1)!, to: IndexPath(row: newRow, section: 1))
// Giving the static cell a reuseidentifier in interface builder
self.tableView.dequeueReusableCell(withIdentifier: "Cell1", for: IndexPath(row: self.subwayOrder+1, section: 1))
根据您要实现的目标,可以通过调用super的实现来成功切换cellForRow
的索引路径。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.