我正在展示一張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)
如果有人有其他替代解決吧!
你怎麼解僱'UIImagePickerController'? – Poles
@Poles當然,編輯後顯示它 – Makaille
你確定你的類是圖像選擇器所需的UINavigationControllerDelegate的子類嗎? – pbush25