When using the built in UIImagePicker from iOS the developer has access to the thumbnail image used in the picker. Is it possible to access the thumbnail used by Filepicker or otherwise access the ALAsset library URL used by Filepicker?
This how I did it, but I must warn you it is slow(ish) and frameworks needed to to this are memory intensive as it iterates over the ALAssetsLibrary looking for posterimages. This on the background thread, so UI changes are sent to the main thread for rendering.
self.assetsLibrary = [[ALAssetsLibrary alloc] init];
NSUInteger groupTypes = ALAssetsGroupAlbum | ALAssetsGroupSavedPhotos | ALAssetsGroupPhotoStream;
[self.assetsLibrary enumerateGroupsWithTypes:groupTypes
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group.posterImage != nil) {
dispatch_async(dispatch_get_main_queue(), ^{
self.pictureLayer.contents = (__bridge_transfer id) CGImageCreateCopy(group.posterImage);
[self.layer setNeedsDisplay];
self.assetsLibrary = nil;
*stop = YES;
});
}
}
failureBlock:^(NSError *error) {
self.assetsLibrary = nil;
NSLog(@"AssetLib error:%@",error);
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With