Sam
Sam

Reputation: 598

Only update visible table view cells?

I'm trying to load a table view with cells that contain images downloaded off the internet. I'd like to only perform the download operation on cells that are currently visible instead of downloading every image as the user scrolls down quickly.

I found the indexPathsForVisibleRows method and that should fit my needs nicely but I need a way to figure out when the table view is no longer scrolling. My idea is to use the indexPathsForVisibleRows when the table view isn't scrolling so that all of the images currently on screen are loaded without unnecessarily loading images.

Are there any methods that I can override or notifications to subscribe to that will alert me when the table view is no longer scrolling?

Thanks!

Upvotes: 1

Views: 168

Answers (1)

Philippe Sabourin
Philippe Sabourin

Reputation: 8075

Take a look at the methods listed here: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html

If your view controller is the delegate of the UITableView, these will also be fired for it, as the UITableView is a subclass of UIScrollView.

Particularly, pay attention to: scrollViewDidEndDecelerating. This is the one I used to do pretty much what you're asking.

Upvotes: 2

Related Questions