【发布时间】:2016-03-31 22:49:56
【问题描述】:
基本上,我有一个列出潜在员工的自定义表格视图单元格。此单元格包括几个标签和一个按钮。我想要的是删除单元格的按钮,但我能找到的只有这个:
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
numbers.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
}
}
这仅允许您在滑动然后选择“删除”时删除单元格
我想我应该在我的 tableViewController.swift 文件中创建一个函数,该函数将删除给定行的单元格,并在我的自定义单元格类中创建一个将调用所述函数的 IBAction。
删除给定行的单元格的函数是什么样的?但是在这种情况下,单元格是否也知道它在哪一行或者是 tableViewController 的工作?
【问题讨论】:
标签: swift uitableview