找不到PHImageResultIsDegradedKey/PHImageFileURLKey [英] PHImageResultIsDegradedKey/PHImageFileURLKey is not found

查看:421
本文介绍了找不到PHImageResultIsDegradedKey/PHImageFileURLKey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 13 beta4不再提供

iOS 13 beta4 no longer gives

1)PHImageFileURLKey 2)图片结果信息键中的PHImageResultIsDegradedKey.

1) PHImageFileURLKey 2) PHImageResultIsDegradedKey in image result info keys.

有人知道找到PHAsset的文件URL的方法吗?

Anyone knows a way to find the fileurl of the PHAsset?

推荐答案

1. PHImageResultIsDegradedKey 现在可在最新的iOS 13 GM和GM2中使用.所以一个问题解决了.

1.PHImageResultIsDegradedKey is now being available in latest iOS 13 GM and GM2. So one problem solved.

2. PHImageFileURLKey 在iOS 13中将不可用,如果您非常需要图像资产的fileURL,并且不需要任何PhotoKit的方法回调就需要它,请在资产描述中使用正则表达式.会起作用的.

2.PHImageFileURLKey won't be available in iOS 13 and if you are in so need of fileURL of an image asset and you need it without any PhotoKit's methods callback go for regex in description of asset. It will work.

您可以使用 + [PHAssetResource assetResourcesForAsset:] 获取PHAssetResource对象的description,使用结果数组中的第一个对象,然后使用正则表达式从字符串中提取fileURL:

You can get the description of a PHAssetResource object using +[PHAssetResource assetResourcesForAsset:] , use first object from resulting array and then extract the fileURL from string using regex:

public static func getFileURLFromPHAssetResourceDescription(description: String) -> String? {
    let regex = try! NSRegularExpression(pattern: "(?<=fileURL: ).*(?=\\s)")
    if let result = regex.firstMatch(in: description, options: [], range: NSRange(location: 0, length: description.count)) {
        let url = String(description[Range(result.range, in: description)!])
        return url
    }
    return nil
}

注意:仅适用于iOS9

Note: Only available from iOS9

这篇关于找不到PHImageResultIsDegradedKey/PHImageFileURLKey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆