我正在尝试从deleteRowsAtIndexPaths更新我的tableView
以使用animation.fade。那么请告诉我如何在有两个阵列时更新tableView
?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! PlacesTableViewCell
cell.title.text = placeArray[indexPath.row]
cell.backgroundImage.image = photoArray[indexPath.row]
return cell
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
println("section and row \(indexPath.section) \(indexPath.row) ")
tableView.beginUpdates()
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
tableView.endUpdates()
}
答案 0 :(得分:1)
试试这个
self.placeArray.removeAtIndex(indexPath.row)
self.photoArray.removeAtIndex(indexPath.row)
self.tablename.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top)
要删除整个部分,请尝试以下操作:
self.placeArray.removeAll(keepCapacity: true)
self.photoArray.removeAll(keepCapacity: true)
self.tablename.deleteSections(NSIndexSet(index: indexPath.section), withRowAnimation: UITableViewRowAnimation.Fade)
希望这会有所帮助。
答案 1 :(得分:0)
在删除所需对象后尝试:[tableView reloadData];