現在の症状
写真選択後に切り抜き画面に移行直後↓のエラーメッセージが出て完了、キャンセルボタンが効かなくなります
切り抜きにはRSKImageCropper
を使用しています
errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}
やった事
以前は現在と同じコードで問題なく動いてました
直近で行ったことはbundle identifier
とsigningのteam
の変更です
この2つ変更直前に問題なかったかは未確認です
コード
swift
1import RSKImageCropper 2 3class DataInput1: UIViewController, UINavigationControllerDelegate ,UIImagePickerControllerDelegate, UITextViewDelegate, UITextFieldDelegate, UIScrollViewDelegate{ 4 5 6 @IBAction func icon(_ sender: Any) { 7 8 if UIImagePickerController.isSourceTypeAvailable(.photoLibrary){ 9 let pickerView = UIImagePickerController() 10 pickerView.sourceType = .photoLibrary 11 pickerView.delegate = self 12 self.present(pickerView, animated: true) 13 }} 14 15 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { 16 17let image = info[.originalImage] as! UIImage 18 self.dismiss(animated: true) 19 20 let imageCropVC = RSKImageCropViewController(image: image, cropMode: .circle) 21 imageCropVC.moveAndScaleLabel.text = "切り取り範囲を選択" 22 imageCropVC.cancelButton.setTitle("キャンセル", for: .normal) 23 imageCropVC.chooseButton.setTitle("完了", for: .normal) 24 present(imageCropVC, animated: true) 25 } 26} 27 28extension DataInput1: RSKImageCropViewControllerDelegate { 29 30 func imageCropViewControllerDidCancelCrop(_ controller: RSKImageCropViewController) { 31 dismiss(animated: true, completion: nil) 32 } 33 34 func imageCropViewController(_ controller: RSKImageCropViewController, didCropImage croppedImage: UIImage, usingCropRect cropRect: CGRect, rotationAngle: CGFloat) { 35 dismiss(animated: true) 36 icon?.setImage(croppedImage, for: .normal) 37 38 39 if controller.cropMode == .circle { 40 UIGraphicsBeginImageContext(croppedImage.size) 41 let layerView = UIImageView(image: croppedImage) 42 layerView.frame.size = croppedImage.size 43 layerView.layer.cornerRadius = layerView.frame.size.width * 0.5 44 layerView.clipsToBounds = true 45 let context = UIGraphicsGetCurrentContext()! 46 layerView.layer.render(in: context) 47 let capturedImage = UIGraphicsGetImageFromCurrentImageContext()! 48 UIGraphicsEndImageContext() 49 let pngData = capturedImage.pngData()! 50 51 let png = UIImage(data: pngData)! 52 icon?.setImage(png, for: .normal) 53 } 54 } 55}
落ちるのではなくフリーズしているのでしょうか?
はい
キャンセルボタン、完了ボタンを押しても落ちずにフリーズしています
ボタンを押しても文字の色が変わらないですか?(変わるならフリーズとは言えません)
あと、軽くググってみましたが、そのメッセージは気にしなくていいらしいので、気にしない(囚われない)ほうがいいと思われます。
はい、文字の色は変わらないです
今他の挙動を確認したら写真は動くのでフリーズでは無かったですすみません。
エラーメッセージはやはり関係ないのですね
解決の手掛りが自分にはこれしか無かったのので囚われてました
imagePickerController(_:info:)の中で、self.dismiss した後に present しているのが気持ち悪いです。
これって、DataInput1が自分を閉じつつRSKImageCropViewControllerを呼び出しているってことですよね?(ちなみに self.dismiss(animated: true) をコメントアウトするとどうなりますか?)
self.dismiss(animated: true) をコメントアウトしたところ
写真選択後の切り抜き画面(質問に乗せている画面)に移行しなくなりました
そのときConsoleになにかメッセージ出てますか?
また、あなたの認識としては「DataInput1が自分を閉じつつRSKImageCropViewControllerを呼び出している」で合ってますか?
Warning: Attempt to present <RSKImageCropViewController: 0x7fa1b38d3600> on <abcd.DataInput1: 0x7fa1b2439a00> whose view is not in the window hierarchy!
となっています
初心者の為深く理解しきれてませんが
私の認識は単に「写真選択画面を閉じつつ
RSKImageCropViewControllerを呼び出している」と認識してしまっていました
RSKImageCropViewControllerを呼び出した後、呼び出し元(DataInput1)が無くなってしまうのはダメです。
DataInput1を閉じた後、(閉じきったあとで)親のViewControllerからRSKImageCropViewControllerを呼び出すようにして下さい。
回答1件
あなたの回答
tips
プレビュー