Your code looks great, which leads me to suspect that the problem is someplace you are not looking - namely, perhaps imageView
itself is nil. This causes imageView.image
to be nil, and so you are imagining that the call to [UIImage imageWithCGImage...]
is failing. But it isn't!
The moral here is: unravel your code a bit more. You wrote this:
imageView.image = [UIImage imageWithCGImage:representation.fullResolutionImage
scale:[representation scale]
orientation:(UIImageOrientation)[representation orientation]];
That's what's hiding the real issue. If only you had written this:
UIImage* image = [UIImage imageWithCGImage:representation.fullResolutionImage
scale:[representation scale]
orientation:(UIImageOrientation)[representation orientation]];
NSLog(@"%@", image);
imageView.image = image;
// ...
... it would have been perfectly clear that you were successfully fetching the image from the asset, but then when you tried to assign it to the image view, the image view was not there to receive it and that was where the ball got dropped.