我添加了自定义滑动以在我的UITableView中的UITableViewCells上共享操作。我的问题是,由于某种原因,它甚至不会让我刷细胞。它立刻崩溃了这条线:
原因:'尝试从更新'
之前的第0部分删除第25行,该第25行只包含25行
但是,我不是想删除任何东西!这是一个分享按钮而不是删除按钮。以下是我添加的相关方法:
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let shareAction = UITableViewRowAction(style: .Normal, title: "Share") { (action: UITableViewRowAction, indexPath: NSIndexPath) -> Void in
// Some stuff
}
shareAction.backgroundColor = UIColor.yellowColor()
return [shareAction]
}
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
}
为什么我的表视图控制器在没有业务尝试删除任何内容时会给我这个错误?
答案 0 :(得分:0)
事实证明这是与上述三种方法无关的问题。我的表视图控制器是一个PFQueryTableViewController子类,它开箱即用numberOfRowsInSection
。我的问题是,当我不应该时,我明确地添加了这种方法。因此,它不应该被调用(它隐含地构建到子类中),导致一些不稳定的行为。我删除了对numberOfRowsInSection
的调用,但它的工作正常。