cocoa - NSCollectionView lazy-loading like behavior -


I'm trying to get behavior like lazy loading from my NSCollectionView. (Honestly I thought it was, like a UITableView - seems like a clear lapse)

Anyway, I am displaying images in cells, and to load images As they are about to scroll into the scene, and unload them after leaving them.

This is for a research tool and it does not need to be beautiful - that is: the content can be in "pop".

Any thoughts? My first idea is to find some kind of footage in the collection when they are on the screen, but drawRect is being said many times, far more often than there are scenes on the screen.

As you mention, NScollectionView Especially if there are so many images inside the cells that create performance related problems, I resolve this problem in this way. There may be a better solution but as far as it is working fine for me, for a long time I have seen the code display with the tool and did not see any downwards

 < Code> -. (Zero) windowDidLoad {// Here is the supervisor for the scrollview of NSCollectionView to keep track of changes in the border. NSView * contentView = [scrollViewOfYourCollectionView contentView]; [[NSNotificationCenter defaultCenter] addObserver: Self Selector: @selector (boundDidChange :) Name: NSViewBoundsDidChangeNotification Object: contentView]; } - (zero) bound Deed Change: (nsnification *) Notification {NSRKT CollectionViewibleCode = Your Collection View. Visible; //collectionViewVisibleRect.size.height + = 300; // You want to preload something for fewer cells ... (int i = 0; I & lt; yourDataSourceArray.count; i ++) {NSCollectionItem * items = [yourCollectionView itemAtIndex: I]; If (NSPointInRect (NSMakePoint (item.view.frame.origin.x, item.view.frame.origin.y), collectionViewVisibleRect) == Yes (if (item.imageView.image == zero) {dispatch_async (dispatch_get_main_queue ( ), ^ {// Fill your cells. // I am using SDWebImage to show / download images.}); }}}}    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -