objective c - How can IOS Photos app can show hundreds of photos in one screen? -


I am working on an application which is showing a lot of photos from multiple sources on the screen.

I am wondering how would Apple have seen "photo tile" in his photo app? With such pictures, I my opinion app should memory warning with little pictures (even if I load photos in "thumbnail" size), but I could see that when I zoom it hundreds screen Can show photos out

In a way I can imagine that this idea is not personal photos, but they are the single 'tile' images produced from real-time photos, so the app only shows 2-3 photos at a time. . But it still requires CPU power and time so that it can be faster. I can zoom in or out instantly.

I want to achieve similar functionality in my app, how to achieve it, it would be great.

Thanks for the reply

IOS 7 Photos.app < / p>

this framework allows you to easily cache images Call thumbnail images with predefined shapes and load items. (Just a "thumbnail" size old Elasat library, you had to change your own size.)

A screen full of 20x20 photo on my test (only my phone screen material 384 images), app 10 MB of memory, and almost no flickering while scrolling. Easy scrolling can be achieved by optimizing cell reloading emos.

This image I used to load images with 20x20 item size.

  @import photos; @ Interface Main View Controller () @ Property (Strong) PHFetchResult * assetsFetchResults; @ Property (strong) PHCaching Image Manager * imageManager; @end   

On viewDialog:

  - (zero) viewDidoad {{Super Viewedload]; Self.imageManager = [[PHCachingImageManager alloc] init]; CGFloat scale = [UIScreen main screen]. Scale; CGSize cellSize = ((UICollectionViewFlowLayout *) self.collectionViewLayout) .itemSize; Asset Grid Thumbnail Size = CGSizeMake (cellSize.Width * Scale, Cells. High * Scale); [Self.collectionView Register Class: [UICollectionViewCell class] forCellWithReuseIdentifier: reuseIdentifier]; Self.assetsFetchResults = [PHAsset fetchAssetsWithOptions: Zero]; // Setup an additional after loading the view}   

and archive view data source methods:

  #pragma icon & lt; UICollectionViewDataSource & gt; - (NSInteger) numberOfSectionsInCollectionView: (UICollectionView *) collectionView {return1; } - (NSInteger) collectionView: (UICollectionView *) CollectionsView NumberOff Item Insight: (NSInteger) section {return self.assetsFetchResults.count; } - (UICollectionViewCell *) collectionView: (UICollectionView *) collectionView cellForItemAtIndexPath: (NSIndexPath *) indexPath {UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier: reuseIdentifier forIndexPath: indexPath]; [Self.imageManager requestImageForAsset: self.assetsFetchResults [indexPath.item] targetSize: CGSizeMake (20, 20) contentMode: PHImageContentModeAspectFill option: zero result handler: ^ (UIImage * result, NSDictionary * info) {UIImageView * imgView = (UIImageView *) [ See cell.contentViewTags: 99 9]; If (! ImgView) {imgView = [[UIImageView alloc] initWithFrame: [cell.contentView limit]]; ImgView.tag = 999; [Cell.contentView addSubview: imgView]; } ImgView.image = Result; }]; // Configure cell return cell; }   

It is!

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -