Skip to content

Instantly share code, notes, and snippets.

@consoledotblog
Forked from mikejahn/Implementation.m
Created June 2, 2014 15:58
Show Gist options
  • Save consoledotblog/08498d25d6d3e75696ed to your computer and use it in GitHub Desktop.
Save consoledotblog/08498d25d6d3e75696ed to your computer and use it in GitHub Desktop.
- (void)setImageWithURL:(NSURL *)url;
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
//here is where you set the image using the one line of code
[cell.imageView setImageWithURL: [NSURL URLWithString:@"https://url/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder"]];
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//here is where you set the image using the one line of code
[cell.imageView setImageWithURL: [NSURL URLWithString:@"https://url/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder"]];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment