gpt4 book ai didi

ios - 从 PHAsset 获取已编辑照片的 URL

转载 作者:搜寻专家 更新时间:2023-10-31 22:10:35 35 4
gpt4 key购买 nike

我正在尝试使用此代码从 PHAsset 获取照片的 URL。

 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`
})

大多数照片使用此代码都运行良好。

当我在“相机”应用中拍照并在“照片”应用中旋转照片,然后在我的应用中选择旋转后的照片时,此代码返回原始照片 URL,而不是旋转后的版本。

如何从 PHAsset 获取已编辑照片的本地 URL?

最佳答案

尝试将返回值更改为“false

If your block returns true, Photos provides the original asset data for editing. Your app uses the adjustment data to alter, add to, or reapply previous edits. (For example, an adjustment data may describe filters applied to a photo. Your app reapplies those filters and allows the user to change filter parameters, add new filters, or remove filters.)

If your block returns false, Photos provides the most recent asset data—the rendered output of all previous edits—for editing.

https://developer.apple.com/documentation/photos/phcontenteditinginputrequestoptions/1624055-canhandleadjustmentdata

 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`
})

关于ios - 从 PHAsset 获取已编辑照片的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46982650/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com