【发布时间】:2017-11-23 12:51:36
【问题描述】:
我有一些表格视图单元格,上面有一些数据,并且单元格上有一个十字按钮(在右上角),单击该按钮应该删除单元格。这就是我尝试删除的方式...
extension sellTableViewController: imageDelegate {
func delete(cell: sellTableViewCell) {
if let indexPath = tableview?.indexPath(for: cell) {
//1.Delete photo from datasource
arrProduct?.remove(at: indexPath.row)
print(self.appDelegate.commonArrForselectedItems)
tableview.deleteRows(at: [indexPath], with: .fade)
}
}
}
但是当我点击十字按钮时,我收到一条错误消息,上面写着The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (2), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'
我的tableviewnumberOfSections和numberOfRowsInSection给出如下...
func numberOfSections(in tableView: UITableView) -> Int {
return (arrProduct?.count)!
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let product = arrProduct![section]
return product.images.count
}
希望有人能帮忙...
【问题讨论】:
标签: ios swift uitableview indexpath