2017-03-06 18 views

回答

1

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

请尝试以下方法 -

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

没有实际上这是在IOS depreceated您捕捉代码9.0 –

+0

你@SaikrishnaBurra HTTPS新的解决方案:// WWW .hackingwithswift.com/example-code/media/uiimagewritetvedvedphotosalbum-how-to-the-ios-photo-album – Meet

+0

没有兄弟......这没有帮助我....完成保存后如何获得图像名称? –

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

即时获取imageUrl为零,谢谢。任何其他方式? –

+0

你确定你得到零,因为我从来没有得到它无这个代码我已经在我目前的应用程序中使用。 –

+0

是的,我得到零.......再次检查...你把图像保存到相册吗? –

相关问题