【问题标题】:Get image name after picking image from Camera through UIImagepickerController and saving it to photos album in ios通过 UIImagepickerController 从 Camera 中选取图像并将其保存到 ios 中的相册后获取图像名称
【发布时间】:2017-07-26 03:22:52
【问题描述】:

我使用功能将图像保存到相机胶卷...

UIImageWriteToSavedPhotosAlbum(imurl!,nil,nil,nil)

如何通过函数获取保存图片的名称或URL??

【问题讨论】:

  • 请展示您在项目中尝试的快照代码

标签: ios iphone swift swift3 ios9


【解决方案1】:

您可以使用 ALAssetsLibrary 框架将图像保存在磁盘上。

请尝试以下方法 -

ALAssetsLibrary().writeImageToSavedPhotosAlbum(editedImage.CGImage, orientation: ALAssetOrientation(rawValue: editedImage.imageOrientation.rawValue)!,
            completionBlock:{ (path:NSURL!, error:NSError!) -> Void in
                print("Image path - \(path)")
        })

【讨论】:

【解决方案2】:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

          let imageUrl = info[UIImagePickerControllerReferenceURL] as! NSURL
          // here you got file path that you select from camera roll

          let image = info[UIImagePickerControllerOriginalImage] as! UIImage
         // here you got image that select from camera roll now just save it

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

【讨论】:

  • 我将 imageUrl 设为 nil ,谢谢。还有什么办法吗?
  • 你确定你得到了 nil,因为我从来没有得到它 nil 这个我已经在我当前的应用程序中使用的代码。
  • 是的,我得到了 nil.......再次检查...您是否将图像保存到相册?
  • 现在我不会将图像保存到相册,而是将图像保存在文件管理器中,然后访问它以进行聊天视图。我只是保存图像的 url 并将其保存在文档目录中
  • 如何将图片保存到文档目录中?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-06
  • 2012-07-24
  • 1970-01-01
  • 2011-08-17
  • 2020-11-04
  • 2021-02-12
  • 1970-01-01
相关资源
最近更新 更多