ios - 在 UIImagePickerController 之上呈现一个 View Controller ,而不是关闭 UIImagePickerController

标签 ios swift uiimagepickercontroller viewcontroller

我正在开发一个应用程序,我必须使用图像选择器 Controller 从手机库导入图像。问题是我必须首先关闭选择器 Controller ,然后在选择器 Controller 关闭后呈现另一个 Controller 。有没有一种方法可以让我不必关闭图像选择器 Controller ,而是呈现 View Controller 或导航 Controller 。顺便说一句,如果我不关闭 imagePickerController,它就会崩溃。其次,我将展示一个传递所选图像的 View Controller 。 谢谢。

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)
}

关于ios - 在 UIImagePickerController 之上呈现一个 View Controller ,而不是关闭 UIImagePickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56891987/

相关文章:

ios - UIImagePickerController 照片预览被未知黑框遮挡

iphone - iOS 4.3 上的cameraOverlayView问题

iphone - 如何将相机按钮添加到 UITabBar 中?

iOS通用应用程序表现得很奇怪

ios - ivar 有两种不同的行为方式,但用法相同

ios - 在 Swift 中使用 Comparable 扩展 @objc 协议(protocol)

core-data - 在 Swift 中使用 CoreData 时无法解包 Optional.None

iphone-sdk-3.0 - 在iPhone 3.0中,尝试使用MessageUI从相机发送图像时,应用程序崩溃

ios - 在 iPhone 6/6+ 中获取错误的屏幕尺寸

ios - 从 Result<T> 转换为不相关的类型 T 时崩溃总是失败