我正在努力找出影响了相当数量用户的错误来源。我正在使用swift 2.0并且配备了崩溃剂,但崩溃报告让我一无所知! :
EXC_BREAKPOINT 0x00000000e7ffdefe
NewGroupShareInstructionsViewController.swift第48行 NewGroupShareInstructionsViewController。(dismissImageView(UIGestureRecognizer) - >())。(闭包#1)
以下是相关代码(如果您需要更多,请告诉我们)
@IBAction func butPreviewPressed(sender: UIButton) {
let imageView = UIImageView(image: UIImage(named: "Step\(sender.tag)"))
imageView.frame = self.view.frame
UIApplication.sharedApplication().keyWindow?.addSubview(imageView)
imageView.frame = CGRectZero
imageView.center = sender.center
let recognizer = UITapGestureRecognizer(target: self, action: "dismissImageView:")
imageView.addGestureRecognizer(recognizer)
imageView.userInteractionEnabled = true
self.lastButtonPressed = sender
UIView.animateWithDuration(0.25) {
self.navigationController?.setNeedsStatusBarAppearanceUpdate()
imageView.frame = UIScreen.mainScreen().bounds
}
}
func dismissImageView(recognizer: UIGestureRecognizer) {
let imageView = recognizer.view!
UIView.animateWithDuration(0.25, animations: {
imageView.frame = CGRectZero
imageView.center = self.lastButtonPressed!.center
}) { (completed) in
if completed {
self.lastButtonPressed = nil
imageView.removeFromSuperview()
self.navigationController?.setNeedsStatusBarAppearanceUpdate()
}
}
}
希望有人可以帮我解决这个问题!
由于
答案 0 :(得分:0)
你有很多力量展开(!
)。我建议您切换到使用if let
语句 - 任何一个unwraps中的任何一个都可能导致崩溃。我最好的猜测是它是self.lastButtonPressed!
调用,因为日志说它在第一个闭包中,就是这样。