【问题标题】:What is equivalent method of ALAsssetsLibrary’s assetForURL:resultBlock:failure in Photos Framework?照片框架中 ALAsssetsLibrary 的assetForURL:resultBlock:failure 的等效方法是什么?
【发布时间】:2016-02-05 22:40:18
【问题描述】:

我正在使用UIImagePickerController 挑选图像,但我还需要图像的名称和其他元数据信息。我可以在选择图像后借助UIImagePickerController 提供的referenceURL 使用ALAsssetsLibrary’sassetForURL:resultBlock:failure 方法获取图像资产,但该方法/框架在iOS9 中已弃用。我在Photos Framework 中搜索了它的等效方法,但没有找到。

让我知道它的等效方法或使用Photos Framework 获取所选图像元数据的任何其他方式。

【问题讨论】:

  • 使用来自Photos.framework+ (PHFetchResult<PHAsset *> *)fetchAssetsWithALAssetURLs:(NSArray<NSURL *> *)assetURLs options:(nullable PHFetchOptions *)options
  • @CuteAngel 谢谢,它成功了...

标签: ios ios9 photosframework assetslibrary


【解决方案1】:

是的,您可以像这样使用照片框架读取元数据;

asset.requestContentEditingInputWithOptions(options) { (fooContentEditingInput: PHContentEditingInput!, _) -> Void in
    //Get full image
    let imageUrl = fooContentEditingInput.fullSizeImageURL
    let orientation = fooContentEditingInput.fullSizeImageOrientation
    var finalImage = CIImage(contentsOfURL: imageUrl)
    finalImage = inputImage.imageByApplyingOrientation(orientation)

    for (key, value) in finalImage.properties() {
        println("key: \(key)")
        println("value: \(value)")
    }
}

【讨论】:

    猜你喜欢
    • 2015-11-04
    • 1970-01-01
    • 2015-08-27
    • 1970-01-01
    • 2019-06-15
    • 1970-01-01
    • 2011-01-21
    • 2011-09-18
    • 1970-01-01
    相关资源
    最近更新 更多