删除cell的操作

作者: iOS_July | 来源:发表于2018-06-11 10:39 被阅读7次
要删除一行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
        }    
    }

相关文章

网友评论

    本文标题:删除cell的操作

    本文链接:https://www.haomeiwen.com/subject/apersftx.html