AXPhotosViewController
final class AXPhotosViewController: UIViewController,
// swiftlint:disable:previous type_body_length
UIPageViewControllerDelegate,
UIPageViewControllerDataSource,
UIGestureRecognizerDelegate,
AXPhotoViewControllerDelegate,
AXNetworkIntegrationDelegate,
AXPhotosTransitionControllerDelegate
AXPhotosViewController
-
The underlying
OverlayViewthat 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
AXTransitionInfopassed in at initialization. Defines functionality for the presentation and dismissal of thePhotosViewController.Declaration
Swift
fileprivate(set) var transitionInfo: AXTransitionInfo -
The
NetworkIntegrationpassed 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
AXPhotosViewControlleris 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
photoIndexThe index of the photo to navigate to
animatedWhether or not to animate the transition
-
Share
Declaration
Swift
@objc func shareAction(_ barButtonItem: UIBarButtonItem)Parameters
barButtonItemUIBarButtonItem
-
Close
Declaration
Swift
@objc func closeAction(_ sender: UIBarButtonItem)Parameters
senderUIBarButtonItem
-
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
keyPathKey path
objectObject observed
changeChange
contextContext
-
Called when the
AXPhotosViewControllernavigates 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
AXPhotosViewControlleris configuring itsOverlayViewfor 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
overlayViewThe
AXOverlayViewthat is being updated.photoThe
AXPhotothe overlay is being configured for.indexThe index of the
AXPhotothat the overlay is being configured for.totalNumberOfPhotosThe total number of photos in the current
dataSource. -
Called when the
AXPhotoViewControllerwill 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
overlayViewThe
AXOverlayViewwhose visibility is changing.visibleA 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
maximumZoomScaleinstead of the default calculated by the library. A good implementation of this method will use a combination of the providedminimumZoomScaleandimageSizeto extrapolate amaximumZoomScaleto return. If theminimumZoomScaleis 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) -> CGFloatParameters
photoThe
Photothat the zoom scale will affect.minimumZoomScaleThe minimum zoom scale that is calculated by the library. This value cannot be changed.
imageSizeThe 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) -> BoolParameters
photoThe 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
photoThe related
AXPhoto.
View on GitHub
AXPhotosViewController Class Reference