Thread 1: signal SIGABRT error when using IBActions?

前端 未结 1 1327
半阙折子戏
半阙折子戏 2021-01-27 08:12

I am trying to create a project using this tutorial. I did the best I could trying to recreate the code but am having some problems. Here is my code:

class ViewC         


        
相关标签:
1条回答
  • 2021-01-27 09:10

    Your code is senseless. You are saying:

    actionSheet.addAction(UIAlertAction(title: "Camera roll", style: UIAlertActionStyle.Default, handler: { ( alert: UIAlertAction!) -> Void in
        imagePickerController.sourceType = UIImagePickerControllerSourceType.Camera
        self.presentViewController(imagePickerController, animated: true, completion: nil)
    } ))
    

    If the user is going to tap a "Camera roll" button, why would you then create an image picker controller with a Camera source type? That isn't what the user asked for.

    The error, by the way, simply means there is no camera. You are not trying to run this code in the Simulator, are you? That would be senseless too. The camera exists only on a device — a device with a camera.

    0 讨论(0)
提交回复
热议问题