NimbusKit
1.2.1 - Fork Nimbus on Github - Visit the Nimbus Wiki
The iOS framework that grows only as fast as its documentation
|
A network-enabled image view that consumes minimal amounts of memory.
Intelligently crops and resizes images for optimal memory use and uses threads to avoid processing images on the UI thread.
Code Breakdown
Initializes the network image view with a preloaded image, usually a "default" image to be displayed until the network image downloads.
We must take care to set the frame before requesting the network image, otherwise the image's display size will be 0,0 and the network image won't be cropped or sized to fit.
If you don't want to modify the frame of the image, you can alternatively specify the display size as a parameter to the setPathToNetworkImage: method.
Code Breakdown
This means: after the image is downloaded, crop and resize the image with an aspect fill content mode. The image returned from the thread will be cropped and sized to fit the imageView perfectly at the given 100x100 dimensions. Because imageView has a contentMode of UIViewContentModeCenter, if we were to make the image view larger the downloaded image would stay in the center of the image view and leave empty space on all sides.
The image being displayed while the network image is being fetched.
This is the same image passed into initWithImage: immediately after initialization. This is used when preparing this view for reuse. Changing the initial image after creating the object will only display the new image if the currently displayed image is is the initial image or nil.
The initial image is drawn only using the view's contentMode. Cropping and resizing are only performed on the image fetched from the network.
A flag for enabling the resizing of images for display.
When enabled, the downloaded image will be resized to fit the dimensions of the image view using the image view's content mode.
When disabled, the full image is drawn as-is. This is generally much less efficient when working with large photos and will also increase the memory footprint.
If your images are pre-cropped and sized then this isn't necessary, but the network image loader is smart enough to realize this so it's in your best interest to leave this on.
By default this is YES.
Options for modifying the way images are cropped when scaling.
By default this is NINetworkImageViewScaleToFitLeavesExcessAndScaleToFillCropsExcess.
The interpolation quality to use when resizing the image.
The default value is kCGInterpolationDefault.
The image memory cache used by this image view to store the image in memory.
The image disk cache used by this image view to store the image on disk.
It may be useful to specify your own image memory cache if you have a unique memory requirement and do not want the image being placed in the global memory cache, potentially pushing out other images.
By default this is [Nimbus imageMemoryCache].
After the image has finished downloading we store it in a disk cache to avoid hitting the network again if we want to load the image later on.
By default this is [ASIDownloadCache sharedCache].
The network operation queue used by this image view to load the image from network and disk.
By default this is [Nimbus networkOperationQueue].
The maximum amount of time that an image will stay in memory after the request completes.
If this value is non-zero then the respone header's expiration date information will be ignored in favor of using this value.
If this value is zero then the response header's max-age value will be used if it exists, otherwise it will use the Expires value if it exists.
A negative value will cause this image to NOT be stored in the memory cache.
By default this is 0.
Delegate for state change notifications.
Designated initializer.
image | This will be the initialImage. |
Load an image from the network using the current frame as the display size.
Loads the image from the memory cache if possible, otherwise fires off a network request with this object's network image information.
Uses self.contentMode to crop and resize the image.
The image's current frame will be used as the display size for the image.
pathToNetworkImage | The network path to the image to be displayed. |
Load an image from the network with a specific display size.
Loads the image from the memory cache if possible, otherwise fires off a network request with this object's network image information.
Uses self.contentMode to crop and resize the image.
pathToNetworkImage | The network path to the image to be displayed. |
displaySize | Used instead of the image's frame to determine the display size. |
Load an image from the network with a specific display size.
Loads the image from the memory cache if possible, otherwise fires off a network request with this object's network image information.
pathToNetworkImage | The network path to the image to be displayed. |
displaySize | Used instead of the image's frame to determine the display size. |
contentMode | The content mode used to crop and resize the image. |
Load an image from the network with a specific display size and crop rect.
Loads the image from the memory cache if possible, otherwise fires off a network request with this object's network image information.
pathToNetworkImage | The network path to the image to be displayed. |
cropRect | x/y, width/height are in percent coordinates. Valid range is [0..1] for all values. |
displaySize | Used instead of the image's frame to determine the display size. |
contentMode | The content mode used to crop and resize the image. |
Load an image from the network with a crop rect and the current frame as the display size.
Loads the image from the memory cache if possible, otherwise fires off a network request with this object's network image information.
Uses self.contentMode to crop and resize the image.
The image's current frame will be used as the display size for the image.
pathToNetworkImage | The network path to the image to be displayed. |
cropRect | x/y, width/height are in percent coordinates. Valid range is [0..1] for all values. |
Load an image from the network with a specific display size.
Loads the image from the memory cache if possible, otherwise fires off a network request with this object's network image information.
The image's current frame will be used as the display size for the image.
pathToNetworkImage | The network path to the image to be displayed. |
contentMode | The content mode used to crop and resize the image. |
Kill any network requests and replace the displayed image with the initial image.
Prepares this view for reuse by cancelling any existing requests and displaying the initial image again.
A network request has begun.
The image has been loaded, either from the network or in-memory.
A network request failed to load.
The operation has started executing.
The operation is about to complete successfully.
This will not be called if the operation fails.
This will be called from within the operation's runloop and must be thread safe.
The operation has completed successfully.
This will not be called if the operation fails.
The operation failed in some way and has completed.
operationDidFinish: will not be called.