0

사진을 찍으려면 UIImagePickerController을 선물하고 있습니다. 문제는 사진을 찍거나 취소하는 것입니다. UIImagePickerController 나는 이전의 흰색 화면이 아닌 ViewController으로 돌아갑니다. 아직 내 navigation bar 만 있습니다. 다른 view (내비게이션 바 포함)을 클릭하면 확인이되고, 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 (animated : true, 완료 : nil)'을 사용하십시오. – Poles

+0

문제는 피커가 아니라 앱에서 조사한 것이고 항상 현재 방법을 사용하고 있습니다.그것은 현재와 navigationController 사이의 갈등과 같습니다. – Makaille

0

는 여기에 내가 카메라를 사용하는 코드입니다.

  • .allowsEditing을 true로 설정합니다. 나는 그것이 차이를 만들고 있다고 생각하지 않습니다.
  • 카메라를 확인 중이지만 질문에 해당 코드를 넣지 않았을 수 있습니다.
  • .modalPresentationStyle을 전체 화면으로 설정합니다. 이것은 귀하의 문제 일 수 있습니다.
  • imagePickerController(picker: didFinishPickingMediaWithInfo) 호출이 표시되지 않습니다. 그러나 그것이 구축되어서는 안되기 때문에 확실히 문제가되지 않습니다.
  • 그 전화 안에는 info의 이미지가 풀려 있습니다. 이것이 귀하의 문제라고 생각합니다. 나는 그 특정 줄에 주석을 달아 이것을 확인해 줄 것을 요청했다.
  • 마지막으로, 다른 뷰 컨트롤러에 segue를 실행하고 있습니다. (내 애플은 다음 "편집"을 "선택"기본적으로.)
+0

안녕하세요, 도와 주셔서 감사합니다하지만 아무것도 바꿀 수 없습니다. 나는 포스트를 업데이트 할 것이고, 문제는 내 네비게이션 컨트롤러 – Makaille

0

전체 화면

+0

가 이미 제안한 방식으로 전화를 걸 때부터 작동하지 않는다. – Makaille