https://github.com/markrickert/remote-image-bug-example
Shows an issue with JMImageCache and remote image loading in PM::TableScreens
https://github.com/markrickert/remote-image-bug-example
Last synced: about 1 year ago
JSON representation
Shows an issue with JMImageCache and remote image loading in PM::TableScreens
- Host: GitHub
- URL: https://github.com/markrickert/remote-image-bug-example
- Owner: markrickert
- Created: 2015-05-12T14:55:26.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-12T15:57:56.000Z (about 11 years ago)
- Last Synced: 2025-02-08T07:27:28.732Z (over 1 year ago)
- Language: Ruby
- Size: 2.18 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
remote-image-bug
===================
An issue where with JMImageCache in a `PM::TableScreen` with remote images, the remote image operation isn't canceled so it keeps setting the image on the reused cells.

Here's how I've solved it in a custom `PM::TableViewCell` with `SDWebImage` which DOES have an operation canceling feature:
```ruby
# Should be included in a custom UITableViewCell
module RemoteImageCell
def prepareForReuse
@image_operation.each do |k,v|
v.cancel
end
@image_operation = {}
end
def set_remote_image(url, image_location = nil)
@image_operation ||= {}
url = NSURL.URLWithString(url) unless url.is_a?(NSURL)
image_location = self.imageView if image_location.nil?
@image_operation[url.absoluteString] = manager.downloadWithURL(url,
options:SDWebImageRefreshCached,
progress:nil,
completed: -> image, error, cacheType, finished {
image_location.image = image unless image.nil?
})
end
def set_placeholder_image(image, image_location = nil)
image_location = self.imageView if image_location.nil?
image_location.image = UIImage.imageNamed(image)
image_location.layer.masksToBounds = true
image_location.layer.cornerRadius = 20
end
def remote_image=(url)
set_remote_image(url)
end
def placeholder_image=(image)
set_placeholder_image(image)
end
def manager
SDWebImageManager.sharedManager
end
end
```