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

Load another image to a UIImageView after one image download has been completed #601

Open
ryuta0201 opened this issue Jun 15, 2021 · 0 comments

Comments

@ryuta0201
Copy link

ryuta0201 commented Jun 15, 2021

Hi, I'm trying to create a function as an extension of UIImageView that loads non-progressive image progressively.
The URL passed to the function provides a progressive PNG image, which seems unable to load progressively even with self.pin_updateWithProgress option being true.

I changed the server's implementation so that the server returns low resolution image when /128 is added to the end of the image's URL.
Then I'm trying to first load that low resolution image ("/128" one) into a UIImageView, followed by another pin_setImage which loads the final high resolution image to the UIImageView, using the low resolution image as placeHolder.

The code looks like the following:

    func setProgressively(url: URL, completion: @escaping (Bool) -> Void) {
        guard let url128 = URL(string: "\(url.absoluteString)/128") else { return }

        self.pin_setImage(from: url128) { [weak self] (result) in
            self?.clear()
            self?.pin_setImage(from: url, placeholderImage: result.image, completion: { [weak self] (finalresult) in
                PINRemoteImageManager.shared().cache.removeObject(forKey: PINRemoteImageManager.shared().cacheKey(for: url128, processorKey: nil))
                self?.pin_updateUI(with: finalresult)
            })
            completion(true)
        }
    }

    func clear() {
        pin_cancelImageDownload()
        pin_clearImages()
    }

However, the UIImageView doesn't update from the low resolution image, or it only loads the high resolution image for some occasions.
Has anybody tried the similar implementation and knows a better practice?

@ryuta0201 ryuta0201 changed the title Load another image to a single UIImageView after one download has been completed Load another image to an UIImageView after one download has been completed Jun 15, 2021
@ryuta0201 ryuta0201 changed the title Load another image to an UIImageView after one download has been completed Load another image to a UIImageView after one download has been completed Jun 15, 2021
@ryuta0201 ryuta0201 changed the title Load another image to a UIImageView after one download has been completed Load another image to a UIImageView after one image download has been completed Jun 15, 2021
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