AXPhotosViewController
final class AXPhotosViewController: UIViewController,
// swiftlint:disable:previous type_body_length
UIPageViewControllerDelegate,
UIPageViewControllerDataSource,
UIGestureRecognizerDelegate,
AXPhotoViewControllerDelegate,
AXNetworkIntegrationDelegate,
AXPhotosTransitionControllerDelegate
AXPhotosViewController
-
The underlying
OverlayView
that is used for displaying photo captions, titles, and actions.Declaration
Swift
let overlayView: AXOverlayView
-
The photos to display in the PhotosViewController.
Declaration
Swift
var dataSource: AXPhotosDataSource { get set }
-
The configuration object applied to the internal pager at initialization.
Declaration
Swift
fileprivate(set) var pagingConfig: AXPagingConfig
-
The
AXTransitionInfo
passed in at initialization. Defines functionality for the presentation and dismissal of thePhotosViewController
.Declaration
Swift
fileprivate(set) var transitionInfo: AXTransitionInfo
-
The
NetworkIntegration
passed in at initialization. TFetches images asynchronously from a cache or URL.- Initialized by the end of
commonInit(dataSource:pagingConfig:transitionInfo:networkIntegration:)
.
Declaration
Swift
fileprivate(set) var networkIntegration: AXNetworkIntegrationProtocol!
- Initialized by the end of
-
The underlying UIPageViewController that is used for swiping horizontally and vertically.
Important
AXPhotosViewController
is this page view controller’sUIPageViewControllerDelegate
,UIPageViewControllerDataSource
. Changing these values will result in breakage.Note
Initialized by the end ofcommonInit(dataSource:pagingConfig:transitionInfo:networkIntegration:)
.Declaration
Swift
fileprivate(set) var pageViewController: UIPageViewController!
-
The internal tap gesture recognizer that is used to hide/show the overlay interface.
Declaration
Swift
let singleTapGestureRecognizer: UITapGestureRecognizer
-
The view controller containing the photo currently being shown.
Declaration
Swift
var currentPhotoViewController: AXPhotoViewController? { get }
-
The index of the photo currently being shown.
Declaration
Swift
private(set) var currentPhotoIndex: Int { get set }
-
init to be used internally by the library
Declaration
Swift
@nonobjc init(dataSource: AXPhotosDataSource? = nil, pagingConfig: AXPagingConfig? = nil, transitionInfo: AXTransitionInfo? = nil, networkIntegration: AXNetworkIntegrationProtocol? = nil)
-
Convenience method to programmatically navigate to a photo
Declaration
Swift
func navigateToPhotoIndex(_ photoIndex: Int, animated: Bool)
Parameters
photoIndex
The index of the photo to navigate to
animated
Whether or not to animate the transition
-
Share
Declaration
Swift
@objc func shareAction(_ barButtonItem: UIBarButtonItem)
Parameters
barButtonItem
UIBarButtonItem
-
Close
Declaration
Swift
@objc func closeAction(_ sender: UIBarButtonItem)
Parameters
sender
UIBarButtonItem
-
KVO observation
Declaration
Swift
override func observeValue(forKeyPath keyPath: String?, // swiftlint:disable:previous block_based_kvo of object: Any?, // swiftlint:disable:next discouraged_optional_collection change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?)
Parameters
keyPath
Key path
object
Object observed
change
Change
context
Context
-
Called when the
AXPhotosViewController
navigates to a new photo. This is defined as when the swipe percent between pages is greater than the threshold (>0.5). If you override this and fail to call super, the corresponding delegate method will not be called!Declaration
Swift
func didNavigateTo(photo: AXPhotoProtocol, at index: Int)
-
Called when the
AXPhotosViewController
is configuring itsOverlayView
for a new photo. This should be used to update the the overlay’s title or any other overlay-specific properties. If you override this and fail to call super, the corresponding delegate method will not be called!Declaration
Swift
func willUpdate(overlayView: AXOverlayView, for photo: AXPhotoProtocol, at index: Int, totalNumberOfPhotos: Int)
Parameters
overlayView
The
AXOverlayView
that is being updated.photo
The
AXPhoto
the overlay is being configured for.index
The index of the
AXPhoto
that the overlay is being configured for.totalNumberOfPhotos
The total number of photos in the current
dataSource
. -
Called when the
AXPhotoViewController
will show/hide itsOverlayView
. This method will be called inside of an animation context, so perform any coordinated animations here. If you override this and fail to call super, the corresponding delegate method will not be called!Declaration
Swift
func overlayView(_ overlayView: AXOverlayView, visibilityWillChange visible: Bool)
Parameters
overlayView
The
AXOverlayView
whose visibility is changing.visible
A boolean that denotes whether or not the overlay will be visible or invisible.
-
If implemented and returns a valid zoom scale for the photo (valid meaning >= the photo’s minimum zoom scale), the underlying zooming image view will adopt the returned
maximumZoomScale
instead of the default calculated by the library. A good implementation of this method will use a combination of the providedminimumZoomScale
andimageSize
to extrapolate amaximumZoomScale
to return. If theminimumZoomScale
is returned (ie.minimumZoomScale
==maximumZoomScale
), zooming will be disabled for this image. If you override this and fail to call super, the corresponding delegate method will not be called!Declaration
Swift
func maximumZoomScale(for photo: AXPhotoProtocol, minimumZoomScale: CGFloat, imageSize: CGSize) -> CGFloat
Parameters
photo
The
Photo
that the zoom scale will affect.minimumZoomScale
The minimum zoom scale that is calculated by the library. This value cannot be changed.
imageSize
The size of the image that belongs to the
AXPhoto
.Return Value
A “maximum” zoom scale that >=
minimumZoomScale
. -
Called when the action button is tapped for a photo. If you override this and fail to call super, the corresponding delegate method will not be called!
Declaration
Swift
func handleActionButtonTapped(photo: AXPhotoProtocol) -> Bool
Parameters
photo
The related
AXPhoto
.Return Value
true if the action button tap was handled, false if the default action button behavior should be invoked.
-
Called when an action button action is completed. If you override this and fail to call super, the corresponding delegate method will not be called!
Note
This is only called for the default action.Declaration
Swift
func actionCompleted(activityType: UIActivity.ActivityType, for photo: AXPhotoProtocol)
Parameters
photo
The related
AXPhoto
.