ios7 - 自定义 UITableViewCell 编辑模式不起作用

标签 ios7 swift ios8 xcode6-beta7

我目前正在开发一款适用于 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/

相关文章:

ios - UISlider 在 iOS7 中没有动画

swift - 使程序化按钮与 Storyboard 按钮的宽度相等

ios - 如何向 UIViewController 扩展添加参数?

ios - CGAffineTransform Identity 与 iOS 8 和 XCode 6 不同(没有自动布局)

ios - 用于保存音频文件的 iCloud - 几个问题

iphone - SpriteKit : Passing data between scenes

google-maps-sdk-ios - iPhone ios7 上的 Google map 上的当前位置看起来很奇怪

objective-c - AVSpeechSynthesizer 在模拟器上工作,但在设备上不工作

ios - 如何使用photokit获取图片库中存储的所有视频文件的url

ios8 - UIDatepicker 显示前一天