-
Notifications
You must be signed in to change notification settings - Fork 23
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
FLImageView notified with FLImageLoadedNotification after image is loaded #1
Comments
I'll have to think about this one. It could potentially raise issues in UITableViewCells where the FLImageViews are reused. If we unregister in imageLoaded, we need to register in loadImageAtURLString. If you are quickly scrolling through, the same FLImageView might register itself twice before an image comes back and then only unregister itself once. If you have some ideas on how this could be implemented safely, then I'd definitely welcome a pull request. Thanks for the report! |
If you call: In that case, no need to addObserver in the init{} methods. Off the top of my head, I'd structure the loadImageAtURLString method as follows:
On the imageLoaded,
I would leave removeObserver on dealloc in case the FLImageView instance is destroyed before it is notified following a recent request. I'll give it a go. |
In FullyLoaded, Add user info for each notification with the URL string of the relevant request. |
+1 to avrahamshuk. It seems like this code was designed under the assumption that when one image loaded, all the rest would likely load really quickly. If I'm not mistaken the following is possible - 10 images call to load their data and the activity shows. Now one image comes back and every image gets the notification. So every image now thinks it's not loading. However, if the 9 other images come back pretty quickly (good network connection or cached would easily do this) then you would get all of those 10 notifications around the same time and therefore all the images would look as though they were loading just fine. Any reason you chose to design this way? The rest of the component looks very good. Thanks! |
FLImageView registers for notifications on FLImageLoadedNotification.
The way things are wired up, after an FLImageView is notified and the image for its URL is fetched etc, it would still get notified on future loads of other images as it only unregisters itself from notifications on dealloc.
Suggestion: Insert removeObserver after an image is received and assigned - hence further notifications won't be dealt with.
The text was updated successfully, but these errors were encountered: