从Camera通过UIImagepickerController选择图像并将其保存到ios

时间:2017-03-06 09:58:00

标签: ios iphone swift swift3 ios9

我使用功能...

将图像保存到相机胶卷

UIImageWriteToSavedPhotosAlbum(imurl!,nil,nil,nil)

如何使用函数获取已保存图像的名称或URL

2 个答案:

答案 0 :(得分:1)

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

请尝试以下方法 -

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

答案 1 :(得分:0)

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