点击破发点时应用程序崩溃 - 斯威夫特

时间:2015-01-12 04:36:01

标签: ios xcode swift breakpoints

我运行应用程序,它工作正常。它做我想做的一切。当我点击一个按钮时,它会因错误而崩溃,"线程1 exc_breakpoint(代码= EXC_1386_BPT,子代码= 0x0)"

我尝试过的事情:

  • 清洁应用
  • 构建应用
  • 测试应用
  • 删除所有@IBOutlets

这是我点击的@IBAction

@IBAction func optionButton(sender: AnyObject) {
       let actionSheetController: UIAlertController = UIAlertController(title: "You Disliked The Displayed Image", message: "Take Your Own Or Choose From Your Library", preferredStyle: .ActionSheet)

    let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
    }

    let takePictureAction: UIAlertAction = UIAlertAction(title: "Take Picture", style: .Default) { action -> Void in
        var takeImage = UIImagePickerController()
        takeImage.delegate = self
        takeImage.sourceType = UIImagePickerControllerSourceType.Camera
        takeImage.allowsEditing = false

        self.presentViewController(takeImage, animated: true, completion: nil)
    }
    let choosePictureAction: UIAlertAction = UIAlertAction(title: "Choose From Camera Roll", style: .Default) { action -> Void in
        var image = UIImagePickerController()
        image.delegate = self
        image.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
        image.allowsEditing = false

        self.presentViewController(image, animated: true, completion: nil)

    }

    actionSheetController.popoverPresentationController?.sourceView = sender as UIView; 
    //Present the AlertController
    self.presentViewController(actionSheetController, animated: true, completion: nil)



    actionSheetController.addAction(choosePictureAction)
    actionSheetController.addAction(takePictureAction)
    actionSheetController.addAction(cancelAction)
}

错误发生在它所说的行上:

actionSheetController.popoverPresentationController?.sourceView = sender as UIView; 

这是我的viewDidLoad方法:

var allImages = [image1,image2,image3,image4,image5,image6,image7,image8,image9,image10,image11,image12,image13,image14]

    var imageCount: Int {
        return Int(arc4random_uniform(UInt32(allImages.count)))
    }

    switch imageCount {
    case 1:
        imageView.image = UIImage(named: "IMG_4183")
    case 2:
        imageView.image = UIImage(named: "IMG_4323")
    case 3:
        imageView.image = UIImage(named: "IMG_4325")
    case 4:
        imageView.image = UIImage(named: "IMG_4327")
    case 5:
        imageView.image = UIImage(named: "IMG_4330")
    case 6:
        imageView.image = UIImage(named: "IMG_4331")
    case 7:
        imageView.image = UIImage(named: "IMG_4335")
    case 8:
        imageView.image = UIImage(named: "IMG_4338")
    case 9:
        imageView.image = UIImage(named: "IMG_4394")
    case 10:
        imageView.image = UIImage(named: "IMG_4400")
    case 11:
        imageView.image = UIImage(named: "IMG_4479")
    case 12:
        imageView.image = UIImage(named: "IMG_4508")
    case 13:
        imageView.image = UIImage(named: "IMG_4772")
    case 14:
        imageView.image = UIImage(named: "IMG_4776")
    default:
        println("didn't set image")
    }

我从未见过这个突破点错误。任何人都可以帮助并向我解释为什么会发生此错误?任何帮助表示赞赏。

0 个答案:

没有答案