从segue(Swift 4)将图像传递到另一个View Controller不显示

时间:2019-04-28 07:03:33

标签: ios swift

将图像传递到第二个View Controller(Swift 4)时未显示,但viewDidLoad显示了图像属性。 UIImageView无显示

  

“可选(大小{1236,822}方向0比例尺1.000000)”

第一个ViewController: ContainerViewController

extension ContainerViewController:  UIImagePickerControllerDelegate, UINavigationControllerDelegate{

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

        if let editedImage = info[UIImagePickerControllerEditedImage] as? UIImage{

 let bVC : BrightnessViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "bVC") as! BrightnessViewController
              bVC.imageName = editedImage

            self.present(bVC, animated: true, completion: nil)
        }

        //Dismiss the UIImagePicker after selection
        picker.dismiss(animated: true, completion: nil)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        picker.isNavigationBarHidden = false
        self.dismiss(animated: true, completion: nil)
    }
}

第二个viewController: BrightnessViewController

    var imageName: UIImage?
    @IBOutlet weak var timg: UIImageView! // myimageview to display image

    override func viewDidLoad() {
        super.viewDidLoad()

        timg.image = imageName
        print(" Image", imageName) // only image property are showing
    }

显示属性:

  

“可选(大小{1236,822}方向0比例1.000000)”

0 个答案:

没有答案