在我的应用中打开 iCloud 图片

Posted

技术标签:

【中文标题】在我的应用中打开 iCloud 图片【英文标题】:Open iCloud Pics in my app 【发布时间】:2016-02-15 06:18:47 【问题描述】:

我必须在我的应用程序中显示所有 iCloud 图片。所以我必须使用这些照片进行进一步的操作。 是否有任何框架可用于实现 iCloud 功能。 我检查了各种代码和 tuts,但无法从 iCloud 中获取图像。

【问题讨论】:

【参考方案1】:

您应该使用 Photos Framework 来访问 iCloud 上的照片。 Photos Framework 也支持照片编辑。

更多详情,您可以点击此链接 - Photos Framework

【讨论】:

【参考方案2】:

也许您正在寻找的是 UIImagePickerControllerDelegate。

让你的类继承 UIImagePickerControllerDelegate;

创建一个函数从库或相机中选择图像,初始化一个pickerController常量,将delegate设置为self,从相机或库中获取pickerController源类型,将allowEditing设置为true并呈现视图控制器。

检查下面的代码:

class YourClass: UIViewController, UIImagePickerControllerDelegate 

    ...

    @IBAction func picImage(sender: UIButton) 

            let pickerController = UIImagePickerController()
            pickerController.delegate = self
            pickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
            pickerController.allowsEditing = true

            self.presentViewController(pickerController, animated: true, completion: nil)

            // before user finish picking image, another func has to run, imagePickerController.
        

        // After user pick the image, this method will dismiss active view controller.
        func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) 

            self.dismissViewControllerAnimated(true, completion: nil)
        

这个看CoreData的链接教程就很好理解了,视频有点长但是值得你看。 感谢 Jason Rybka,https://www.youtube.com/watch?v=1kCKlv1npw0。

适用于 Swift 2.1 / ios 9.2。

祝你好运。

【讨论】:

以上是关于在我的应用中打开 iCloud 图片的主要内容,如果未能解决你的问题,请参考以下文章

使用“iCloud”和“在我的 Mac 上”打开对话框?

无需用户从 DocumentBrowser 中选择即可呈现 iCloud 文件

从 icloud 打开文件时,Swift 4 应用程序崩溃

在 Mac 应用程序中的保存对话框中包含 iCloud

NSWorkspace openURL 未使用文件类型的默认应用程序打开存储在 iCloud Drive 中的文件

如何在 Swift 中以编程方式打开 icloud 应用程序(文件)