通过UIImagePickerController从相机中选择图像后获取图像名称,并将其保存到iOS中的照片专辑中



i用功能将图像保存到相机卷中...

uiimagewritetosavedphotosalbum(imurl!,nil,nil,nil)

如何通过功能获取保存图像的名称或URL ??

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

请尝试以下方法 -

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

最新更新