问题描述
我正在尝试使用此代码从PHAsset
获取照片的URL.
I'm trying to get a photo's URL from a PHAsset
using this code.
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
asset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
guard let url = contentEditingInput?.fullSizeImageURL else {
observer.onError(PHAssetError.imageRequestFailed)
return
}
/// Using this `url`
})
大多数照片与此代码配合良好.
Most of the photos are working well with this code.
当我在相机"应用中拍摄照片并在照片"应用中旋转照片,然后在我的应用中选择旋转的照片时,此代码将返回原始照片URL,而不是旋转的版本.
When I take a photo in the Camera app and rotate the photo in the Photos app, then select the rotated photo in my app, this code returns the original photo URL -- not the rotated version.
如何从PHAsset
获取经过编辑的照片的本地URL?
How can I get the edited photo's local URL from PHAsset
?
推荐答案
尝试将返回值更改为" false "
Try changing your return to "false"
如果您的区块返回false,则照片"会提供最新的资产 数据-以前所有编辑的渲染输出-进行编辑.
If your block returns false, Photos provides the most recent asset data—the rendered output of all previous edits—for editing.
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return false
}
asset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
guard let url = contentEditingInput?.fullSizeImageURL else {
observer.onError(PHAssetError.imageRequestFailed)
return
}
/// Using this `url`
})
这篇关于从PHAsset获取经过编辑的照片的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!