swift - ios13 使用 PHImageManager 获取原始图像

标签 swift phasset ios13 phimagemanager

在 ios 13 PHImageManagerMaximumSize 上不起作用。

调用时

let manager = PHImageManager.default()
let option = PHImageRequestOptions()
option.isSynchronous = synchronous
option.isNetworkAccessAllowed = true
option.resizeMode = .exact

manager.requestImage(for: asset, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFill, options: option, resultHandler: {(result, info) in
})

requestImage 返回错误: 错误域=NSCocoaErrorDomain Code=-1 "(null)"

此代码在 ios12 上运行良好

请问如何在ios13上获取原图?

最佳答案

引自 Apple 文档 here :

When you use the PHImageManagerMaximumSize option, Photos provides the largest image available for the asset without scaling or cropping. (That is, it ignores the resizeMode option.)

但是在这种情况下,resizeMode 似乎在 iOS 13 上生效。

resizeMode 设置为 .none 使 PHImageManagerMaximumSize 按预期工作。

关于swift - ios13 使用 PHImageManager 获取原始图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57658263/

相关文章:

ios - 从 ICloud 获取图像将卡住 UI

swift - 从 ReferenceURL : fetchAssets(withALAssetURLs:options:) DEPRECATED 获取 PHAsset

ios - 通用功能在同一环境中表现不同

ios - 在 swift 中实现 GTScrollNavigationBar

ios - 如何开发一个自定义的 UICollectionViewLayout,它具有带有自动调整单元格的交错列?

iOS:PHAsset & 检测 DNG RAW 格式

ios - swift fetchAssetsInAssetCollection : Loading Photos From Range in Camera Roll

ios - Xamarin.iOS statusBar BackgroundColor不会更改

ios - Swift/iOS13 - 在 ViewController 中访问 SceneDelegate 窗口变量

ios - 苹果登录后注销