Skip to content

Instantly share code, notes, and snippets.

@sergiosvieira
Created June 14, 2013 18:25
Show Gist options
  • Save sergiosvieira/5784119 to your computer and use it in GitHub Desktop.
Save sergiosvieira/5784119 to your computer and use it in GitHub Desktop.
Try to reduce the size of images
If you cannot reduce the size for any reasons, try the below code (operationQueue is an ivar of the instance of NSOperationQueue)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
[operationQueue addOperationWithBlock:^{
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"name" ofType:@"jpg"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.imageView.image = image;
}];
}];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment