@IBAction func onlytest(_ sender: Any) {
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
let actionSheet = UIAlertController(title: "Choose image source", message: nil, preferredStyle: UIAlertControllerStyle.actionSheet)
actionSheet.addAction(UIAlertAction(title: "Camera roll", style: UIAlertActionStyle.default, handler: { ( alert: UIAlertAction!) -> Void in
imagePickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary
self.present(imagePickerController, animated: true, completion: nil)
} ))
actionSheet.addAction(UIAlertAction(title: "Take Photo", style: UIAlertActionStyle.default, handler: { ( alert: UIAlertAction!) -> Void in
imagePickerController.sourceType = UIImagePickerControllerSourceType.camera
self.present(imagePickerController, animated: true, completion: nil)
} ))
actionSheet.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil))
self.present(actionSheet, animated: true, completion: nil)
}
当我点击拍照时,我收到以下错误:
libc ++ abi.dylib:以NSException类型的未捕获异常终止“使应用程序崩溃
然而,当我点击相机胶卷时,它可以正常工作。
连接没有错误。有没有人有想法?