1

解析服务器:2.2.17(自托管)

解析-SDK-iOS-OSX:1.14.2

ParseUI-iOS 版本:1.2.0

Xcode 7.3.1,斯威夫特

我是 IOS 编程的新手(20 周),并构建了一个用于娱乐和学习的应用程序。

在许多带有部分的 TableViewController 之一中,我喜欢调用 editActionsForRowAtIndexPath。向左滑动时会引发错误:

2016-08-12 18:14:44.967 myParseCustomLoginTest[54158:729475] * 断言失败 -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/ UITableView.m:1422 2016-08-12 18:14:44.974 myParseCustomLoginTest[54158:729475] *由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“尝试从第 0 节中删除第 68 行,该行在更新'

信息:

0)如果我在第一部分滑动,则会引发错误。

1) 是的,没错,在我的第一部分,我有 4 行。

2) 我无法在以下部分向左滑动。我只能在第一部分滑动。

3) 表、节和行本身都很好(就像 Parse Server 的源数据一样)。

4) editActionsForRowAtIndexPath 的相同代码适用于没有部分的同一个表。

代码:class MenuSectionedPFQueryTableViewController: PFQueryTableViewController -> 我认为它工作正常,因为表格、部分和行都很好。

扩展 MenuSectionedPFQueryTableViewController numberOfSectionsInTableView numberOfRowsInSection titleForHeaderInSection cellForRowAtIndexPath -> 我认为它工作正常,因为表、部分和行都很好。

在扩展 MenuSectionedPFQueryTableViewController我有这个代码:

override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool{
    return indexPath.section == 0 ? true : false
}

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {

    // Add to diary slider
    let shareAction = UITableViewRowAction(style: .Normal, title: "Add to diary") { (action: UITableViewRowAction, indexPath: NSIndexPath) in
        // create menuItem object
        let menuItem = self.objects![indexPath.row]

        // create menu object
        let menuObject = PFObject(className: "ffdUserDiary")

        // reference menu to pointer ffdDB2Pointer
        let ex = PFObject(className: "ffdDB")
        ex.objectId = menuItem.objectId
        print(menuItem.objectId)
        menuObject.setObject(ex, forKey: "ffdDBPointer")

        // reference current user to pointer userPointer
        menuObject["userPointer"] = PFUser.currentUser()

        // add x + y to diary
        menuObject["x"] = menuItem.objectForKey("x")
        menuObject["y"] = menuItem.objectForKey("y")

        // save menuObject
        // menuObject.saveEventually()
        menuObject.saveInBackgroundWithBlock { (success, error) in
            if let error = error {
                print("error: \(error.localizedDescription)")
            } else {
                print("success: \(success)")
            }
        }

        // tableView.reloadData()
    }
    shareAction.backgroundColor = UIColor.redColor()
    return [shareAction]
}

我认为这是 indexPath 的错误,但无法修复它。有任何想法吗?

4

0 回答 0