在 UIImagePickerController 之上呈现一个视图控制器,而不是关闭 UIImagePickerController
Present a view controller on top of UIImagePickerController instead of dismissing the UIImagePickerController
我正在开发一个应用程序,我必须在其中使用图像选择器控制器从 phone 的库中导入图像。问题是我必须首先关闭选择器控制器,然后在选择器控制器关闭后呈现另一个控制器。有没有一种方法我不必关闭图像选择器控制器,而是呈现一个视图控制器或一个导航控制器。顺便说一句,如果我不关闭 imagePickerController,它就会崩溃。其次,我展示了一个视图控制器,它传递被选择的图像。
谢谢。
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let shViewController = SHViewController()
if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
shViewController.image = editedImage
} else if let originalImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
shViewController.image = originalImage
}
shViewController.delegate = self
dismiss(animated: true, completion: nil)
present(shViewController, animated: true, completion: nil)
}
您不能从同一个 vc 中展示 2 vc,所以要么
picker.present(shViewController, animated: true, completion: nil)
或
dismiss(animated:false) {
self.present(shViewController, animated: true, completion: nil)
}
我正在开发一个应用程序,我必须在其中使用图像选择器控制器从 phone 的库中导入图像。问题是我必须首先关闭选择器控制器,然后在选择器控制器关闭后呈现另一个控制器。有没有一种方法我不必关闭图像选择器控制器,而是呈现一个视图控制器或一个导航控制器。顺便说一句,如果我不关闭 imagePickerController,它就会崩溃。其次,我展示了一个视图控制器,它传递被选择的图像。 谢谢。
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let shViewController = SHViewController()
if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
shViewController.image = editedImage
} else if let originalImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
shViewController.image = originalImage
}
shViewController.delegate = self
dismiss(animated: true, completion: nil)
present(shViewController, animated: true, completion: nil)
}
您不能从同一个 vc 中展示 2 vc,所以要么
picker.present(shViewController, animated: true, completion: nil)
或
dismiss(animated:false) {
self.present(shViewController, animated: true, completion: nil)
}