0

私は写真を撮るためにUIImagePickerControllerを提示しています。写真を撮るか、キャンセルするかどうかです。UIImagePickerController私は前回のViewControllerで白い画面に戻ります。私のnavigation barだけがまだここにあります。他のview(ナビゲーションバー付き)をクリックしてもOKですが、UIImagePickerControllerと呼ばれるタブに戻ると、まだ白です。現在のUIImagePickerControllerの後に白い画面

let picker = UIImagePickerController(); 
picker.delegate = self; 
picker.mediaTypes = [swiftString]; 
picker.allowsEditing = true 

picker.sourceType = UIImagePickerControllerSourceType.camera; 
picker.cameraCaptureMode = .photo 
self.present(picker, animated:true, completion:nil); 

却下

picker.dismiss(animated: true, completion:nil); 

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { 
    picker.dismiss(animated: true, completion:nil); 
} 

誰かがアイデア感謝の持っている場合は!

更新:私はpresent methodとの見解を呼び出すとき

白い画面が常に表示されます。誰かがそれを解決するために、他の選択肢を持っている場合

guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {return} 
appDelegate.navigationController.present(picker, animated: true, completion: nil) 

:だから私は、これは私の問題を解決する

それはナビゲーションコントローラ(階層...)との競合だと思います!

+0

から.modalPresentationStyleを設定し、あなたが 'UIImagePickerController'を却下されている方法は? – Poles

+0

@Polesもちろん、ポストはそれを示すように編集されています – Makaille

+0

イメージピッカーに必要なクラスをUINavigationControllerDelegateのサブクラスにしてもよろしいですか? – pbush25

答えて

0

picker.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContextを使用して、イメージピッカーを提示してください。私は別の物事のカップルに気付い

func openCameraApp() { 
    if UIImagePickerController.availableCaptureModes(for: .rear) != nil { 
     picker.allowsEditing = false 
     picker.sourceType = UIImagePickerControllerSourceType.camera 
     picker.cameraCaptureMode = .photo 
     picker.modalPresentationStyle = .fullScreen 
     present(picker, 
       animated: true, 
       completion: nil) 
    } else { 
     noCamera() 
    } 
} 
func noCamera(){ 
    let alertVC = UIAlertController(
     title: "No Camera", 
     message: "Sorry, this device has no camera", 
     preferredStyle: .alert) 
    let okAction = UIAlertAction(
     title: "OK", 
     style:.default, 
     handler: nil) 
    alertVC.addAction(okAction) 
    present(
     alertVC, 
     animated: true, 
     completion: nil) 
} 

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { 
    let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage // do you have this line in your code? 
    image = chosenImage 
    self.performSegue(withIdentifier: "ShowEditView", sender: self) 
    dismiss(animated: true, completion: nil) 
} 
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { 
    dismiss(animated: false, completion: nil) 
} 

+0

これは私の意見を完全に消してしまい、すべてのボタンが機能せず、ピッカーが表示されません。 – Makaille

+0

imagepickerを終了するには 'imagePicker.parent?.dismiss(アニメーション:true、完了:なし)'を使用します。 – Poles

+0

問題はピッカーからではなく、私はアプリで調査しています、そして、私は常に現在の方法を使用しています。それは現在とnavigationControllerの間の葛藤のようなものです – Makaille

0

は、ここで私はカメラに使用するコードです。

  • .allowsEditingをtrueに設定しました。私はそれが違いを生み出しているとは思わない。
  • 私はカメラをチェックしていますが、おそらくそのコードをあなたの質問に入れなかったでしょう。
  • .modalPresentationStyleを全画面に設定しています。これはあなたの問題かもしれません。
  • imagePickerController(picker: didFinishPickingMediaWithInfo)コールが表示されません。しかし、それは構築すべきではないので、間違いなく問題ではない。
  • infoから画像をアンラップします。 これはあなたの問題だと私は信じています。私はその特定の行にコメントをして、これを確認するように頼んだ。
  • 最後に、別のビューコントローラにセグを実行しています。 (私のアプリは、「編集」を「選択」は基本的である。)
+0

こんにちは、ありがとうございましたが、何も変わりません。私はポストを更新します、問題は、私のナビゲーションコントローラ – Makaille

0

がフルスクリーン

+0

が既に提案した、現在のメソッドを呼び出すことから来て、動作しません – Makaille

関連する問題