UIImagePickerController didFinishPickingImage没有在Swift 3中调用

UIImagePickerController didFinishPickingImage没有在Swift 3中调用,第1张

概述我正在尝试使用imagePickerView从照片库加载图像.我更新了我的plist以获取 Xcode 8的照片库,如下所示. 之后,更新了plist.I可以访问照片库.但是,Picker图像没有加载到我的imageView. 我的代码: 注意: 下面的代码用于Xcode 7而不是Xcode 8? import UIKit class ViewController: UIViewContr 我正在尝试使用imagePickerVIEw从照片库加载图像.我更新了我的pList以获取 Xcode 8的照片库,如下所示.

之后,更新了pList.I可以访问照片库.但是,Picker图像没有加载到我的imageVIEw.

我的代码:

注意:
下面的代码用于Xcode 7而不是Xcode 8?

import UIKit   class VIEwController: UIVIEwController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {   let imagePicker = UIImagePickerController()   @IBOutlet weak var imageVIEw: UIImageVIEw!   overrIDe func vIEwDIDLoad() {    super.vIEwDIDLoad()    // Do any additional setup after loading the vIEw,typically from a nib.        imagePicker.delegate = self   }   @IBAction func library(_ sender: UIbutton) {    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photolibrary) {        imagePicker.delegate = self        imagePicker.sourceType = UIImagePickerControllerSourceType.photolibrary;        imagePicker.allowsEditing = true        self.present(imagePicker,animated: true,completion: nil)     }   }

代码更新:来自rmaddy回答:

func imagePickerController(_ picker: UIImagePickerController,dIDFinishPickingMediawithInfo info: [String : Any]) {       if let image = info[UIImagePickerControllerOriginalimage] as? UIImage {          imageVIEw.image = image     }       picker.dismiss(animated: true,completion: nil);    }

提前致谢….

解决方法 在Swift 3中,您需要使用正确的委托方法:

func imagePickerController(_ picker: UIImagePickerController,dIDFinishPickingMediawithInfo info: [String : Any]) {    if let image = info[UIImagePickerControllerOriginalimage] as? UIImage {        imageVIEw.image = image    }    picker.dismiss(animated: true,completion: nil);}
总结

以上是内存溢出为你收集整理的UIImagePickerController didFinishPickingImage没有在Swift 3中调用全部内容,希望文章能够帮你解决UIImagePickerController didFinishPickingImage没有在Swift 3中调用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1017458.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存