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

Flickering bug in tableview. #17

Open
catarino opened this issue Jul 22, 2012 · 3 comments
Open

Flickering bug in tableview. #17

catarino opened this issue Jul 22, 2012 · 3 comments

Comments

@catarino
Copy link

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

@shnhrrsn
Copy link
Member

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.

@catarino
Copy link
Author

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. :)

@catarino
Copy link
Author

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

  • (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    [self loadVisibleRowsImages];
    }
    */
  • (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    if(!decelerate) {
    [self loadVisibleRowsImages];
    }
    }

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

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

2 participants