The photo album scroll data source.
This data source emphasizes speed and memory efficiency by requesting images only when they're needed and encouraging immediate responses from the data source implementation.
[NIPhotoAlbumScrollViewDataSource] Fetching Required Album Information
|(UIImage *)||- photoAlbumScrollView:photoAtIndex:photoSize:isLoading:originalPhotoDimensions:|
[NIPhotoAlbumScrollViewDataSource] Optimizing Data Retrieval
[NIPagingScrollViewDataSource] Fetching Required Album Information
< NIPagingScrollViewPage > *)
Fetches the highest-quality image available for the photo at the given index.
Your goal should be to make this implementation return as fast as possible. Avoid hitting the disk or blocking on a network request. Aim to load images asynchronously.
If you already have the highest-quality image in memory (like in an NIImageMemoryCache), then you can simply return the image and set photoSize to be NIPhotoScrollViewPhotoSizeOriginal.
If the highest-quality image is not available when this method is called then you should spin off an asynchronous operation to load the image and set isLoading to YES.
If you have a thumbnail in memory but not the full-size image yet, then you should return the thumbnail, set isLoading to YES, and set photoSize to NIPhotoScrollViewPhotoSizeThumbnail.
Once the high-quality image finishes loading, call didLoadPhoto:atIndex:photoSize: with the image.
This method will be called to prefetch the next and previous photos in the scroll view. The currently displayed photo will always be requested first.
Called when you should cancel any asynchronous loading requests for the given photo.
When a photo is not immediately visible this method is called to allow the data source to minimize the number of active asynchronous operations in place.
This method is optional, though recommended because it focuses the device's processing power on the most immediately accessible photos.
Fetches the total number of pages in the scroll view.
The value returned in this method will be cached by the scroll view until reloadData is called again.
Fetches a page that will be displayed at the given page index.
You should always try to reuse pages by calling dequeueReusablePageWithIdentifier: on the paging scroll view before allocating a new page.