Reputation: 8967
I would like to know how people implement an asynchronous UIImageView loading, if you have it inside a custom UITableViewCell, I've seen quite some examples using GCD, subclassing UIImageView.. all of them must involves NSURLRequest and NSURLConnection. So how do people do this in a subclass of UITableViewCell that has an UIImageView in it?
Upvotes: 1
Views: 1950
Reputation: 4879
Look at this category: SDWebImage. It's a image downloader for UIImageView
. You place you're image view in your cell, and in the - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
method, just use:
[myImageView setImageWithURL:[NSURL URLWithString:@"example.com/myimage.jpg"]];
Upvotes: 1
Reputation: 12405
Here is a very good tutorial which explains asynchronous loading in general....
You can use the same idea to load your image view..
Upvotes: 0
Reputation: 3809
I think the simple and ideal way to do this is to do the following steps
cellForRowAtIndexPath:
check if the image is available locally load it, else fire off nsurl request to download it in a separate thread and show a loading indicator image.Upvotes: 0