照片库的图像未显示



照片库的图像未显示。我的应用就像我的应用

我在这个应用程序中的目标是 2 分。第一件事是当我输入"照片选择"按钮时,我可以选择照片库的图像。第二件事是在UIImageView中显示库的图像,但这不能做到。我可以访问照片库,选择图片,但图片未显示。光电控制器是

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

我认为连接是可以的,所以必要的代码不在 PhotoController 中,对吧?但是我不知道添加此照片控制器的代码。如何解决此问题?

由于此委托方法在 Swift 3.1 中已弃用,因此请改用此方法。

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        let image = info[UIImagePickerControllerOriginalImage] as! UIImage
        self.myImageView.image = image
        self.dismiss(animated: true, completion: nil)
}

相关内容

  • 没有找到相关文章

最新更新