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

performance main thread #32

Open
Zhingel opened this issue Aug 2, 2024 · 0 comments
Open

performance main thread #32

Zhingel opened this issue Aug 2, 2024 · 0 comments

Comments

@Zhingel
Copy link

Zhingel commented Aug 2, 2024

`func image(size: CGSize, resultClosure: @escaping (UIImage?)->()) -> PHImageRequestID {
let requestSize = CGSize(width: size.width * UIScreen.main.scale, height: size.height * UIScreen.main.scale)

    let options = PHImageRequestOptions()
    options.isNetworkAccessAllowed = true
    options.deliveryMode = .fastFormat

    return PHCachingImageManager.default().requestImage(
        for: self,
        targetSize: requestSize,
        contentMode: .aspectFill,
        options: options,
        resultHandler: { image, info in
            DispatchQueue.main.async {      // add this
                resultClosure(image) // called for every quality approximation
            } 
        }
    )
}`

and also don't use geometry reader for getting cell size, because it's kill performance too, you should got cell size from UIScreen.main.bounds

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

1 participant