【问题标题】:Custom UITableViewCell editing mode not working自定义 UITableViewCell 编辑模式不起作用
【发布时间】:2014-09-06 10:51:31
【问题描述】:

我目前正在开发一个适用于 iOS 7 和 iOS 8 的应用程序,它使用 Xcode 6 build 7 和 Swift 进行编码。在其中一个视图控制器中,我得到了一个带有自定义单元格的 tableview,问题是,当我将 tableview 属性编辑设置为“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
}

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

谢谢!!

【问题讨论】:

标签: ios7 swift ios8 xcode6-beta7


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-19
    • 2018-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多