【发布时间】:2015-03-27 05:46:50
【问题描述】:
我正在尝试删除表格视图中的一行。我已经实现了所需的方法,但是当我水平滑动行时,没有删除按钮出现。我已经搜索过,并且到处都找到了相同的解决方案,但在我的情况下它不起作用。我不知道我在哪里犯错。任何人都可以帮助我吗?
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool
{
return true
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
{
if editingStyle == .Delete
{
dataHandler.deletePeripheral(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
}
}
【问题讨论】:
-
我想你检查函数语法
-
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
-
@LeonardoSavioDabus 我使用了与你建议的相同的语法,我也更新了我的问题,但删除按钮仍然没有出现。
-
我发现@Nilesh 下面的答案有效。我错过了查看删除按钮的约束。
标签: ios uitableview swift