@IBAction func AlertStart(_ sender: Any) { // UIAlertController let alertController:UIAlertController = UIAlertController(title:"Which one will you take?", message: "choose one",preferredStyle: .actionSheet) let actionChoise1 = UIAlertAction(title: "Take Photo", style: .default){ action in // カメラ起動! let camera = UIImagePickerController.SourceType.camera if UIImagePickerController.isSourceTypeAvailable(camera) { let picker = UIImagePickerController() picker.sourceType = camera picker.delegate = self as? UIImagePickerControllerDelegate & UINavigationControllerDelegate self.present(picker, animated: true, completion: nil) } } let actionCancel = UIAlertAction(title: "Cancel", style: .cancel){ (action) -> Void in } // actionを追加 alertController.addAction(actionChoise1) alertController.addAction(actionCancel) // UIAlertControllerの起動 present(alertController, animated: true, completion: nil) }
actionSheetでTake Photoをタップしたらカメラを起動させたいのですがその際にエラーが発生してしまいます。
プライバシーの設定などはしてあります。カメラなので実機で起動させています。
エラーの対処のためにlet cameraの部分の警告と出てきたところは修正などを加えましたがやはり動きません。
どうすればよろしいのでしょうか。ご意見をよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/11/12 08:55