我目前正在开发一款适用于 iOS 7 和 iOS 8 的应用程序,使用 Xcode 6 build 7 使用 Swift 进行编码。在其中一个 View Controller 中,我得到了一个带有自定义单元格的表格 View ,问题是,当我将表格 View 属性编辑设置为“true”时,没有任何反应,我没有看到删除按钮,但是如果我使用默认单元格而不是我的,它起作用了。
我已经使用了所有必要的方法
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
}
但是没有任何反应,有人遇到过同样的问题吗?
谢谢!!
最佳答案
好的解决了,毕竟解决方案一直摆在我面前,问题是我在单元格的 layoutSubviews 方法中做的事情,但是我完全忘记调用 super.layoutSubviews,当我这样做的时候,一切都很完美。
关于ios7 - 自定义 UITableViewCell 编辑模式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25699473/