0

Photo library's image is not shown. My app is like my app

My goal in this app is 2 points.First thing is when I put "PhotoSelect" button,I can select photo library's image.Second thing is to be shown the library's image in UIImageView but this cannot be done.I can access photo library, select picture but the picture is not shown. PhotoController is

import Foundation
import UIKit
class PhotoController:UIViewController,UINavigationControllerDelegate,UIImagePickerControllerDelegate{

    @IBOutlet weak var myImageView: UIImageView!

    @IBAction func PhotoSelect(_ sender: Any) {
        let myPickerController = UIImagePickerController()
        myPickerController.delegate = self;
        myPickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary

        self.present(myPickerController, animated: true, completion: nil)

    }

    @IBAction func PhotoSend(_ sender: Any) {
    }

    private func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])

    {
        myImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage

        self.dismiss(animated: true, completion: nil)

    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //myImageUploadRequest()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

  }

I think connection is ok, so necessary code is not in PhotoController,right?But I do not know the code to add this PhotoController.How can fix this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user8080149
  • 59
  • 1
  • 7

1 Answers1

0

Because this delegate method is deprecated in Swift 3.1, use this method instead.

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        let image = info[UIImagePickerControllerOriginalImage] as! UIImage
        self.myImageView.image = image
        self.dismiss(animated: true, completion: nil)
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Irshad Ahmad
  • 1,363
  • 11
  • 17