import UIKit class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func viewDidAppear(_ animated: Bool) { let picker = UIImagePickerController() picker.sourceType = .camera picker.delegate = self present(picker, animated: true, completion: nil) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { print(#function) // print(info[UIImagePickerControllerMediaType]!) let image = info[UIImagePickerControllerOriginalImage] as! UIImage // 撮影した画像をカメラロールに保存 UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) } func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { print(#function) } }
console // なに?
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.