下記のようにコードを書いていますが、buildingすると libc++abi.dylib: terminating with uncaught exception of type NSException というエラー(?)が出てしまいます。
何か原因かわかる方助けていただければ幸いです。
swift3
1func changeColor(_ sender: UITapGestureRecognizer) { selectImage()} 2 3 4 5 private func selectImage() { 6 let alertController = UIAlertController(title: "画像を選択", message: nil, preferredStyle: .actionSheet) 7 let cameraAction = UIAlertAction(title: "写真を撮る", style: .default) { (UIAlertAction) -> Void in 8 self.selectFromCamera() 9 } 10 let libraryAction = UIAlertAction(title: "カメラロールから選択", style: .default) { (UIAlertAction) -> Void in 11 self.selectFromLibrary() 12 } 13 let cancelAction = UIAlertAction(title: "キャンセル", style: .cancel) { (UIAlertAction) -> Void in 14 self.dismiss(animated: true, completion: nil) 15 } 16 alertController.addAction(cameraAction) 17 alertController.addAction(libraryAction) 18 alertController.addAction(cancelAction) 19 present(alertController, animated: true, completion: nil) 20 } 21 22 private func selectFromCamera() { 23 if UIImagePickerController.isSourceTypeAvailable(.camera) { 24 let imagePickerController = UIImagePickerController() 25 imagePickerController.delegate = self 26 imagePickerController.sourceType = UIImagePickerControllerSourceType.camera 27 imagePickerController.allowsEditing = true 28 self.present(imagePickerController, animated: true, completion: nil) 29 } else { 30 print("カメラ許可をしていない時の処理") 31 } 32 } 33 34 private func selectFromLibrary() { 35 if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) { 36 let imagePickerController = UIImagePickerController() 37 imagePickerController.delegate = self 38 imagePickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary 39 imagePickerController.allowsEditing = true 40 self.present(imagePickerController, animated: true, completion: nil) 41 } else { 42 print("カメラロール許可をしていない時の処理") 43 } 44 } 45 46 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { 47 48 if let image = info[UIImagePickerControllerEditedImage] { 49 self.showAlert.image = image as? UIImage 50 } 51 52 picker.dismiss(animated: true, completion: nil) 53 } 54
デバッグエリアの「libc++abi.dylib: terminating with uncaught exception of type NSException」と表示されるより前の行に、もし「Terminating app due to uncaught exception ...」などと書かれた部分があれば、そちらもご提示いただけるでしょうか。
erminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setImage:]: unrecognized selector sent to instance 0x135e5a400' *** First throw call stack: (0x1820a9900 0x181717f80 0x1820b061c 0x1820ad5b8 0x181fb168c 0x10003574c 0x100035b6c 0x18724b3d4 0x18c7ecfa8 0x18c830cb8 0x18a7131a4 0x1015a1bb0 0x1015b21b4 0x1015a1bb0 0x1015a7658 0x182060bb0 0x18205ea18 0x181f8d680 0x18349c088 0x186e04d90 0x100044a8c 0x181b2e8b8) このように出ております。

回答1件
あなたの回答
tips
プレビュー