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

Overview

A single photo view that supports zooming and rotation.

Inheritance diagram for NIPhotoScrollView:
<NIPagingScrollViewPage> <NIRecyclableView>

Tasks

(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
 
State
NSInteger pageIndex property
 
CGSize photoDimensions property
 
UITapGestureRecognizer * doubleTapGestureRecognizer property
 
(UIImage *) - image
 
(NIPhotoScrollViewPhotoSize) - photoSize
 
(void) - setImage:photoSize:
 

Method Documentation

zoomingIsEnabled

Whether the photo is allowed to be zoomed.

@property (nonatomic) BOOL zoomingIsEnabled;
Discussion

By default this is YES.

zoomingAboveOriginalSizeIsEnabled

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

@property (nonatomic) BOOL zoomingAboveOriginalSizeIsEnabled;
Discussion

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 Photos.app allows small photos to be zoomed in.

Attention
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.

doubleTapToZoomIsEnabled

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

@property (nonatomic) BOOL doubleTapToZoomIsEnabled;
Discussion

Available on iOS 3.2 and later.

By default this is YES.

maximumScale

The maximum scale of the image.

@property (nonatomic) CGFloat maximumScale;
Discussion

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.

photoScrollViewDelegate

The photo scroll view delegate.

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

pageIndex

The index of this photo within a photo album.

@property (nonatomic) NSInteger pageIndex;

photoDimensions

The largest dimensions of the photo.

@property (nonatomic) CGSize photoDimensions;
Discussion

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.

doubleTapGestureRecognizer

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

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

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

image

The currently-displayed photo.

- (UIImage*)image;

photoSize

The current size of the photo.

- (NIPhotoScrollViewPhotoSize)photoSize;
Discussion

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

setImage:photoSize:

Set a new photo with a specific size.

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

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

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

pageDidDisappear

Called after the page has gone off-screen.

- (void)pageDidDisappear;
Discussion

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.

setFrameAndMaintainState:

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

- (void)setFrameAndMaintainState:(CGRect)frame;
Discussion

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.

reuseIdentifier

The identifier used to categorize views into buckets for reuse.

@property (nonatomic, copy) NSString* reuseIdentifier;
Discussion

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.

prepareForReuse

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

- (void)prepareForReuse;