0
votes

I have a bit of code that takes a thumbnail, applies a CoreImage filter to it, then sets it to a custom UITableViewCell's imageView property:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
    ^{
        CIImage *inputImage = [[CIImage imageWithCGImage:self.thumbnail.CGImage]retain];
        CIFilter *filter =    [[CIFilter filterWithName:@"CISepiaTone" keysAndValues:
                                kCIInputImageKey, inputImage,
                                @"inputIntensity", [NSNumber numberWithFloat:1.0],
                                nil] retain];
        CIImage *outputImage = [[filter outputImage] retain];
        CGImageRef cgimage = [self.context createCGImage:outputImage fromRect:[outputImage extent]];
        filtersTableViewCellItem.thumbnail = [UIImage imageWithCGImage:cgimage];

        [filter release];
        [outputImage release];
        [inputImage release];
        CGImageRelease(cgimage);

        dispatch_async(dispatch_get_main_queue(),
        ^{
            UITableViewCell *tableViewCell = [[self cellForRowAtIndexPath:indexPath] retain];

            if (tableViewCell)
            {
                [filtersTableViewCell.activityIndicatorView stopAnimating];
                filtersTableViewCell.imageView.image = filtersTableViewCellItem.thumbnail;
            }

            [tableViewCell release];
        });
    });

The thumbnail is being produced properly, however it is not updating itself on the imageView. I've tried doing setNeedsDisplay to not avail. The funny thing is, when I've used similar code like this, but haven't used a custom UITableViewCell, it's worked perfectly fine. Anyone have any insight as to why this might not be working?

3

3 Answers

1
votes

Try reloading that cell:

[self.tableView reloadRowsAtIndexPath:indexPath withAnimation:UITableViewRowAnimationAutomatic]
1
votes

This was happening because I was doing some loading of the UITableViewCell in its layoutSubviews method (I was setting the frame of the UIImageView) and this was running into some conflict with my GCD thread. I moved all of this code to layoutSubviews and now it works fine.

0
votes

Couple of things for you to check -

First, is it possible you did not have a custom view set up for that nib file? I had the same problem. I created a UIview subclass for that view controller, went into Interface Builder and set the view to that UIView subclass and then added an import header for the UIView into the Controller class. thats what did it for me