本文介绍了如何从UIImagePickerController检索PHAsset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检索PHAsset,但是iOS 8不推荐使用PHAsset.fetchAssets(withALAssetURLs:options :),所以如何正确检索PHAsset?

I'm trying to retrieve a PHAsset however PHAsset.fetchAssets(withALAssetURLs:options:) is deprecated from iOS 8 so how can I properly retrieve a PHAsset?

推荐答案

我遇到了同样的问题,首先检查权限并请求访问权限:

I had the same the issue, first check permissions and request access:

let status = PHPhotoLibrary.authorizationStatus()

if status == .notDetermined  {
    PHPhotoLibrary.requestAuthorization({status in

    })
}

只需将其挂接到触发UIImagePickerController的任何对象上即可.现在,委托调用应该在userInfo中包含PHAsset.

Just hook that up to whatever triggers your UIImagePickerController. The delegate call should now include the PHAsset in the userInfo.

guard let asset = info[UIImagePickerControllerPHAsset] as? PHAsset

这篇关于如何从UIImagePickerController检索PHAsset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 06:40