I am puzzled that no one can answer this question ...
So, in the end, I figured out how to achieve the exact effect that is used in the actual app store in terms of how the icons are loaded / displayed.
Take a sample LazyTableImages project and make some simplified modifications.
Go to the root view controller and remove all checks regarding scrolling and / or slowing down the table in cellForRowAtIndexPath
Remove all calls to loadImagesForOnScreenRows and thus remove this method.
Go to IconDownload.m and change the startDownload method to not make the async image downlaod, but instead load synchronization in the background thread. Delete all the code in startDownload and add the following so that it looks like this:
- (void)startDownload { NSOperationQueue *queue = [NSOperationQueue new]; NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(loadImage) object:nil]; [queue addOperation:operation]; [operation release]; [queue release]; }
Then add loadImage, for example:
- (void)loadImage { NSData *imageData = [[NSData alloc] initWithContents OfURL:[NSURL URLWithString:appRecord.imageURLString]]; self.apprecord.appIcon = [UIImage imageWithData:imageData]; [imageData release]; [self performSelectorOnMainThread:@selector(notifyMainThread) withObject:nil waitUntilDone:NO]; }
- (void)loadImage { NSData *imageData = [[NSData alloc] initWithContents OfURL:[NSURL URLWithString:appRecord.imageURLString]]; self.apprecord.appIcon = [UIImage imageWithData:imageData]; [imageData release]; [self performSelectorOnMainThread:@selector(notifyMainThread) withObject:nil waitUntilDone:NO]; }
Then add notifyMainThread as follows:
- (void)notifyMainThread { [delegate appImageDidLoad:self.indexPathInTableView]; }
- (void)notifyMainThread { [delegate appImageDidLoad:self.indexPathInTableView]; }
Done! Launch it and you will see the exact behavior of the application store, no longer waiting for the request to download images until the scrolling stops, and will no longer wait for images to appear until the scrolling stops or until the user removes his finger from the screen .
Images are loaded as soon as the cell is ready for display, and the image is displayed immediately after its loading, period.
Sorry for any typos, I didn’t paste this from my application, I typed it, since now I am far from my mac ...
In any case, I hope this helps you all ...
bpatrick100
source share