应用程序在手机上运行时崩溃,在模拟器上运行正常

时间:2015-08-07 05:01:00

标签: ios swift exc-bad-access

http://i.imgur.com/CIRCGy2.png

以上是我得到的唯一错误。通常这种情况发生在我对一个不存在的按钮的引用时。问题是,如果是这种情况,它也会在SIM卡中崩溃。如上所述,它在模拟器中运行得非常好,但是当我在iPhone上测试它时崩溃了。我能想到的唯一一件事就是sdk是8.4而我是8.1。

崩溃日志

http://pastebin.com/fhFr4eBz

按钮

@IBAction func topButton(sender: AnyObject) {
    var nicebutton = sender as! UIButton

    nicebutton.enabled = false

    var nopebutton = nicebutton.superview?.viewWithTag(102) as! UIButton

    nopebutton.enabled = true

    let hitPoint = sender.convertPoint(CGPointZero, toView: self.tableView)
    let hitIndex = self.tableView.indexPathForRowAtPoint(hitPoint)
    let object = objectAtIndexPath(hitIndex)
    object.incrementKey("count")
    object.save()
    self.tableView.reloadRowsAtIndexPaths([hitIndex!], withRowAnimation: UITableViewRowAnimation.None)
}


@IBAction func bottomButton(sender: AnyObject) {

    var nopebutton = sender as! UIButton

    nopebutton.enabled = false

    var nicebutton = nopebutton.superview?.viewWithTag(101) as! UIButton

    nicebutton.enabled = true
    let hitPoint = sender.convertPoint(CGPointZero, toView: self.tableView)
    let hitIndex = self.tableView.indexPathForRowAtPoint(hitPoint)
    let object = objectAtIndexPath(hitIndex)
    object.incrementKey("count", byAmount: -1)
    object.saveInBackground()
    self.tableView.reloadRowsAtIndexPaths([hitIndex!], withRowAnimation: UITableViewRowAnimation.None)
}

编辑 - 非常感谢你们这几天在这里寻求帮助。你真的帮助我对自己的身体有了一个想法。感谢那些让我失望的人。

2 个答案:

答案 0 :(得分:0)

我认为你因为以错误的方式重新加载表格视图而崩溃了

你应该像这样重新加载

tableView.beginUpdates()
tableView.reloadRowsAtIndexPaths([hitIndex!], withRowAnimation: UITableViewRowAnimation.None)
tableView.endUpdates()

答案 1 :(得分:0)

这很有趣。这段代码破坏的全部原因是因为我试图在appdelegate上全局隐藏tabbar。我的电话充满了激情,只是拒绝开始。我必须从头开始重做它才能找到答案。

相关问题