Open catarino opened 12 years ago
Assuming you're talking about images, it's most likely EGOCache, but I'm unsure of a great way to fix this in EGOCache itself without unnecessarily complicating things. It's something that should be managed/"fixed" outside of EGOCache.
As soon as I have the time, I'm going to update EGOCache and EGOImageLoading to take full advantage of modern technologies and use NSCache as well, but in the mean time, here's how we do it in our own apps now:
We have NSCache and EGOCache side by side, with NSCache preventing EGOCache from ever reading from disk if it doesn't need to. This speeds up scroll view performance quite a bit and will definitely reduce flickering all on its own. Be careful with what you set your NSCache totalCost to, if you go too low, you're rendering it useless, too high and you're leaving way too many images in memory.
Another big thing to do here is to not nil out images in prepareForReuse/didMoveToSuperview and only set them to nil when you know the next image isn't the same as the image currently in place (note: should definitely still cancel any images that may be loading, but don't nil out the old ones yet). UITableView (and UICollectionView on iOS6) is pretty good about reusing the same cell for each row when you call reloadData, so you can save yourself the extra calls and prevent the flicker if the data is the same. Meaning, if you have imageA in NSIndexPath 0,0, and imageB in 0,1, when you call reloadData, UITableView will most likely already give you reused cells with imageA for 0,0 and imageB for 0,1. Niling them out in prepareForReuse would cost more in this scenario than its worth and cause a flicker.
Hi Shaun,
thank you so much for such a detailed reply.
yep it's for the avatar images in my weddar app leaderboard screen.
I'm not the iOS developer for the project (I'm the founder/designer/ manager) so I don't have much knowledge on the subject but will pass the message.
again, thank you. :)
Hi Shaun,
I've managed to fix this issue that Xcode 4.5 brought. Code below
/* Bug fixed This caused the leaderboard flickering bug before v1.7.9
I'm no expert dev. this was trial & error so I'm not sure but, although we use it there I don't think it was related to EGOCache.
Still commenting on this issue, because someone else might bump in a situation like this.
Thanks
Still trying to figure out if it's just EGOCache since I've updated several libs (JSONKit, AFNetworking) But I think it's EGOCache related