Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHector Romero
6,151 PointsthumbnailImageAtTime deprecated in iOS 7
In iOS 7 thumbnailImageAtTime is deprecated, what method can we use instead of it to do the same thing?
1 Answer
Stone Preston
42,016 Pointsthis stack overflow post shows how to do it using av foundation:
add the CoreMedia and AVFoundation libraries to your project (click the plus sign under Link Binary with Libraries in your projects build phases and add those 2) then:
import AVFoundation first:
#import <AVFoundation/AVFoundation.h>
then you can use:
AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:partOneUrl options:nil];
AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];
generate1.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(1);
CGImageRef oneRef = [generate1 copyCGImageAtTime:time actualTime:NULL error:&err];
UIImage *one = [[UIImage alloc] initWithCGImage:oneRef];
[_firstImage setImage:one];
_firstImage.contentMode = UIViewContentModeScaleAspectFit;