The best way to get thumbnails with ALAssetsLibrary

混江龙づ霸主 提交于 2019-12-06 03:09:50
Shamsudheen TK

Use AlAsset aspectRatioThumbnail instead of fullResolutionImage for high performance

The class ALAsset has two methods to get thumbnails:

- (CGImageRef)thumbnail
- (CGImageRef)aspectRatioThumbnail

example:

//ALAssetsLibrary block will execute in a separate thread. So I suggest to do the UI related stuff in main thread.
dispatch_sync(dispatch_get_main_queue(), ^{

   CGImageRef iref = [myasset aspectRatioThumbnail];
   itemToAdd.image = [UIImage imageWithCGImage:iref];

 });//end block

I think in this https://github.com/johnil/JFImagePickerController project with two classes JFAssetHelper and JFImageManager you will find answer.This use NSCache to cache photos and it really quick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!