swift3 – Xcode 8 – swift 3:创建一个未知类型的图像格式是一个错误

swift3 – Xcode 8 – swift 3:创建一个未知类型的图像格式是一个错误,第1张

概述使用UI ImagePicker选择图像时出错: [Generic] Creating an image format with an unknown type is an error 我正在使用Xcode 8.1和Swift 3. 我已经搜遍了网络,但似乎没有解决我的问题,请帮忙! 这是我的代码: class TabBarController: UITabBarController, UIIma 使用UI ImagePicker选择图像时出错:
[Generic] Creating an image format with an unkNown type is an error

我正在使用Xcode 8.1和Swift 3.
我已经搜遍了网络,但似乎没有解决我的问题,请帮忙!

这是我的代码:

class TabbarController: UITabbarController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {var isSelected: Bool = falsevar imgPicker: UIImagePickerController = UIImagePickerController()overrIDe func vIEwDIDLoad() {    super.vIEwDIDLoad()    //imgPicker = UIImagePickerController()    imgPicker.delegate = self    imgPicker.allowsEditing = false    imgPicker.sourceType = .photolibrary}func imagePickerController(_ picker: UIImagePickerController,dIDFinishPickingMediawithInfo info: [String : Any]) {    imgPicker.dismiss(animated: true,completion: nil)    if let image = info[UIImagePickerControllerOriginalimage] as? UIImage {        self.performSegue(withIDentifIEr: "topostPicture",sender: image)    }}func imagePickerControllerDIDCancel(_ picker: UIImagePickerController) {    dismiss(animated: true,completion: nil)}func askImagePickerSource(sender: UIVIEwController) {    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {        let alert = UIAlertController(Title: nil,message: nil,preferredStyle: .actionSheet)        let cameraAction = UIAlertAction(Title: "Camera",style: .default,handler: { (action: UIAlertAction) in            self.imgPicker.sourceType = .camera            self.imgPicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .camera)!            sender.present(self.imgPicker,animated: true,completion: nil)        })        let photolibraryAction = UIAlertAction(Title: "Photo library",handler: { (action: UIAlertAction) in            self.imgPicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photolibrary)!            sender.present(self.imgPicker,completion: nil)        })        let cancelAction = UIAlertAction(Title: "Cancel",style: .cancel) { (UIAlertAction) in            sender.dismiss(animated: true,completion: nil)        }        alert.addAction(cameraAction)        alert.addAction(photolibraryAction)        alert.addAction(cancelAction)        sender.present(alert,completion: nil)    } else {        self.imgPicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photolibrary)!        sender.present(self.imgPicker,completion: nil)    }}overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {    if segue.IDentifIEr == "topostPicture" {        if let postPictureVC = segue.destination as? PostPictureVC {            if let image = sender as? UIImage {                postPictureVC.image = image            }        }    }}

}

我通过不为UIImagePickerController添加委托作为’self’来面对同样的问题.添加后,我能够从图库中获取所选图像.但即使将委托添加为自己并能够访问图像(在ImageVIEw上显示),我仍然得到相同的错误.经过对SO的进一步研究后,我发现这只是一个错误,不会以任何方式影响应用程序.

另见“Creating an image format with an unknown type is an error Objective-C Xcode 8”

总结

以上是内存溢出为你收集整理的swift3 – Xcode 8 – swift 3:创建一个未知类型的图像格式是一个错误全部内容,希望文章能够帮你解决swift3 – Xcode 8 – swift 3:创建一个未知类型的图像格式是一个错误所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存