2014-09-06 38 views
0

我目前正在使用Xcode 6 build 7编码Swift的iOS 7和iOS 8应用程序。在其中一个视图控制器中,我得到了一个带有自定义单元格的tableview,事实是,当我将tableview属性编辑设置为“true”时,什么都没有发生,我没有看到删除按钮,但是如果我使用默认单元格而不是我的工作。自定义UITableViewCell编辑模式不起作用

我用所有必要的方法

func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { 
    return true 
} 

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 
    if (editingStyle == UITableViewCellEditingStyle.Delete) { 
     // handle delete (by removing the data from your array and updating the tableview) 
    } 
} 

func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle { 
    return .Delete 
} 

但没有任何反应,任何人有过同样的问题?

谢谢!

回答

2

好的解决了,毕竟解决方案总是在我面前,事情是在layoutSubviews方法的单元格中,我正在做的事情,但我完全忘记了调用super.layoutSubviews,当我做到了这一切都很完美。

相关问题