Swift基础入坑

删除cell的操作

2018-06-11  本文已影响7人  iOS_July
要删除一行cell需要的操作:

1、删除动作的用户交互

2、删除行对应的数据

3、形影行从界面上消失

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            // Delete the row from the data source
            areas.remove(at: indexPath.row)
            provinces.remove(at: indexPath.row)
            parts.remove(at: indexPath.row)
            areaImages.remove(at: indexPath.row)
            visited.remove(at: indexPath.row)
            
            tableView.deleteRows(at: [indexPath], with: .fade)
        } else if editingStyle == .insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
上一篇 下一篇

猜你喜欢

热点阅读