Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS15以上获取图片的path会失败 #681

Open
qiuqixiang opened this issue Jan 6, 2022 · 2 comments
Open

iOS15以上获取图片的path会失败 #681

qiuqixiang opened this issue Jan 6, 2022 · 2 comments

Comments

@qiuqixiang
Copy link

Issue Description

Description and Steps

Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.

Info

ZLPhotoBrowser version: e.g. 4.2.1
Device: e.g. iPhone X
Device version: e.g. iOS 15.0
Xcode version: e.g. Xcode 13.2

Configuration code of ZLPhotoConfiguration

Paste your code here.

Error loading image : Error Domain=NSCocoaErrorDomain Code=260 "未能打开文件“IMG_4557.PNG”,因为它不存在。" UserInfo={NSFilePath=/var/mobile/Media/DCIM/104APPLE/IMG_4557.PNG, NSUnderlyingError=0x114c41b80 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

@HemingTai
Copy link

HemingTai commented Oct 13, 2022

@longitachi 有一些图片选择了之后打不开,具体方法在下面,这个函数返回的路径,用try Data(contentsOf: url)获取图片数据时会报错,提示路径不存在,麻烦帮忙看一下。
@objc public class func fetchAssetFilePath(asset: PHAsset, completion: @escaping (String?) -> Void) { asset.requestContentEditingInput(with: nil) { (input, info) in var path = input?.fullSizeImageURL?.absoluteString if path == nil, let dir = asset.value(forKey: "directory") as? String, let name = asset.value(forKey: "filename") as? String { path = String(format: "file:///var/mobile/Media/%@/%@", dir, name) } completion(path) } }

@longitachi
Copy link
Owner

虽然提供了这个获取路径的方法,但是一直没试过,iOS15之前通过这种方法能读取到data吗?我刚用14.1模拟器试了下也不行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants