The iOS framework that grows only as fast as its documentation
NIPhotoScrollView Class Reference


A single photo view that supports zooming and rotation.

Inheritance diagram for NIPhotoScrollView:
<NIPagingScrollViewPage> <NIRecyclableView>


(void) - pageDidDisappear
(void) - setFrameAndMaintainState:
NSString * reuseIdentifier property
(void) - prepareForReuse
Configuring Functionality
BOOL zoomingIsEnabled property
BOOL zoomingAboveOriginalSizeIsEnabled property
BOOL doubleTapToZoomIsEnabled property
CGFloat maximumScale property
id< NIPhotoScrollViewDelegatephotoScrollViewDelegate property
NSInteger pageIndex property
CGSize photoDimensions property
UITapGestureRecognizer * doubleTapGestureRecognizer property
(UIImage *) - image
(NIPhotoScrollViewPhotoSize) - photoSize
(void) - setImage:photoSize:

Method Documentation


Whether the photo is allowed to be zoomed.

@property (nonatomic) BOOL zoomingIsEnabled;

By default this is YES.


Whether small photos can be zoomed at least until they fit the screen.

@property (nonatomic) BOOL zoomingAboveOriginalSizeIsEnabled;

If this is disabled, images smaller than the view size can not be zoomed in beyond their original dimensions.

If this is enabled, images smaller than the view size can be zoomed in only until they fit the view bounds.

The default behavior in allows small photos to be zoomed in.

This will allow photos to be zoomed in even if they don't have any more pixels to show, causing the photo to blur. This can look ok for photographs, but might not look ok for software design mockups.

By default this is YES.


Whether double-tapping zooms in and out of the image.

@property (nonatomic) BOOL doubleTapToZoomIsEnabled;

Available on iOS 3.2 and later.

By default this is YES.


The maximum scale of the image.

@property (nonatomic) CGFloat maximumScale;

By default this is 0, meaning the view will automatically determine the maximum scale. Setting this to a non-zero value will override the automatically-calculated maximum scale.


The photo scroll view delegate.

@property (nonatomic, weak) id<NIPhotoScrollViewDelegate> photoScrollViewDelegate;


The index of this photo within a photo album.

@property (nonatomic) NSInteger pageIndex;


The largest dimensions of the photo.

@property (nonatomic) CGSize photoDimensions;

This is used to show the thumbnail at the final image size in case the final image size is smaller than the album's frame. Without this value we have to assume that the thumbnail will take up the full screen. If the final image doesn't take up the full screen, then the photo view will appear to "snap" to the smaller full-size image when the final image does load.

CGSizeZero is used to signify an unknown final photo dimension.


The gesture recognizer for double-tapping zooms in and out of the image.

@property (nonatomic, readonly, strong) UITapGestureRecognizer* doubleTapGestureRecognizer;

This is used mainly for setting up dependencies between gesture recognizers.


The currently-displayed photo.

- (UIImage*)image;


The current size of the photo.

- (NIPhotoScrollViewPhotoSize)photoSize;

This is used to replace the photo only with successively higher-quality versions.


Set a new photo with a specific size.

- (void)setImage:(UIImage *)image photoSize:(NIPhotoScrollViewPhotoSize)photoSize;

If image is nil then the photoSize will be overridden as NIPhotoScrollViewPhotoSizeUnknown.

Resets the current zoom levels and zooms to fit the image.


Called after the page has gone off-screen.

- (void)pageDidDisappear;

This method should be used to reset any state information after a page goes off-screen. For example, in the Nimbus photo viewer we reset the zoom scale so that if the photo was zoomed in it will fit on the screen again when the user flips back and forth between two pages.


Called when the frame of the page is going to change.

- (void)setFrameAndMaintainState:(CGRect)frame;

Use this method to maintain any state that may be affected by the frame changing. The Nimbus photo viewer uses this method to save and restore the zoom and center point. This makes the photo always appear to rotate around the center point of the screen rather than the center of the photo.


The identifier used to categorize views into buckets for reuse.

@property (nonatomic, copy) NSString* reuseIdentifier;

Views will be reused when a new view is requested with a matching identifier.

If the reuseIdentifier is nil then the class name will be used.


Called immediately after the view has been dequeued from the recycled view pool.

- (void)prepareForReuse;