PSPDFDocumentViewInteractions
Objective-C
@protocol PSPDFDocumentViewInteractions <NSObject>
Swift
protocol DocumentViewInteractions : NSObjectProtocol
A protocol that provides a collection of customizable interaction components.
-
Component responsible for selecting annotations.
This component is backed by several gesture recognizers, including long press and tap gesture recognizers. This component provides an additional activation context that contains information about the annotation being selected and a page view that contains it.
You can take advantage of component activation conditions to allow or disallow annotation selection based on the given context and location. For example, to disallow selecting annotations of a specific type (say, ink annotations), you can write:
selectAnnotation.addActivationCondition { context, _, _ in !(context.annotation is InkAnnotation) }
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<PSPDFAnnotationSelectionContext *> *_Nonnull selectAnnotation;
Swift
var selectAnnotation: InteractionComponent<AnnotationSelectionContext<Annotation>> { get }
-
Attempts to select an annotation at the given location.
Note
This method will respect the activation conditions of
selectAnnotation
interaction component but it will ignore itsenabled
property.Declaration
Objective-C
- (BOOL)tryToSelectAnnotationAtPoint:(CGPoint)point inCoordinateSpace: (nonnull id<UICoordinateSpace>)coordinateSpace;
Swift
func tryToSelectAnnotation(at point: CGPoint, in coordinateSpace: UICoordinateSpace) -> Bool
Parameters
point
Location of touch.
coordinateSpace
Coordinate space of
point
.Return Value
true
if the attempt to select an annotation succeeded as the result of calling this method, otherwisefalse
. -
Component responsible for discarding annotation selection and ending editing form elements and free text annotations.
This component is backed by a tap gesture recognizer. This component provides no additional activation context.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull deselectAnnotation;
Swift
var deselectAnnotation: InteractionComponent<NSNull> { get }
-
Component responsible for showing the action sheet for link annotations and starting editing form elements and free text annotations.
This component is backed by several gesture recognizers, including long press and tap gesture recognizers. This component provides an additional activation context that contains information about an annotation or form element being edited and a page view that contains it.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<PSPDFAnnotationSelectionContext *> *_Nonnull editAnnotation;
Swift
var editAnnotation: InteractionComponent<AnnotationSelectionContext<Annotation>> { get }
-
Attempts to begin editing an annotation at the given location.
Note
This method will respect the activation conditions of
editAnnotation
interaction component but it will ignore itsenabled
property.Declaration
Objective-C
- (BOOL)tryToEditAnnotationAtPoint:(CGPoint)point inCoordinateSpace: (nonnull id<UICoordinateSpace>)coordinateSpace;
Swift
func tryToEditAnnotation(at point: CGPoint, in coordinateSpace: UICoordinateSpace) -> Bool
Parameters
point
Location of touch.
coordinateSpace
Coordinate space of
point
.Return Value
true
if the attempt to begin editing an annotation succeeded as the result of calling this method, otherwisefalse
. -
Component responsible for moving, rotating and resizing annotations.
This component is backed by a long press gesture recognizer. This component provides an additional activation context that contains additional information about a transformation mode, an annotation being transformed a the page view that contains it.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<PSPDFAnnotationTransformationContext *> *_Nonnull transformAnnotation;
Swift
var transformAnnotation: InteractionComponent<AnnotationTransformationContext<Annotation>> { get }
-
Component responsible for “opening” link annotations, or, in other words, executing their action.
This component is backed by a tap gesture recognizer. This component provides an additional activation context that contains information about a link annotation being opened and a page view that contains it.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent< PSPDFAnnotationSelectionContext<PSPDFLinkAnnotation *> *> *_Nonnull openLinkAnnotation;
Swift
var openLinkAnnotation: InteractionComponent<AnnotationSelectionContext<LinkAnnotation>> { get }
-
Attempts to open a link annotation at the given location.
Note
This method will respect the activation conditions of
openLinkAnnotation
interaction component but it will ignore itsenabled
property.Declaration
Objective-C
- (BOOL)tryToOpenLinkAnnotationAtPoint:(CGPoint)point inCoordinateSpace: (nonnull id<UICoordinateSpace>)coordinateSpace;
Swift
func tryToOpenLinkAnnotation(at point: CGPoint, in coordinateSpace: UICoordinateSpace) -> Bool
Parameters
point
Location of touch.
coordinateSpace
Coordinate space of
point
.Return Value
true
if the attempt to open a link annotation succeeded as the result of calling this method, otherwisefalse
. -
Component responsible for showing annotation creation/pasting menu.
This component is backed by a long press gesture recognizer. This component provides no additional activation context.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull showAnnotationMenu;
Swift
var showAnnotationMenu: InteractionComponent<NSNull> { get }
-
Attempts to show an annotation creation/pasting and menu at the given location.
Note
This method will respect the activation conditions of
showAnnotationMenu
interaction component but it will ignore itsenabled
property.Declaration
Objective-C
- (BOOL)tryToShowAnnotationMenuAtPoint:(CGPoint)point inCoordinateSpace: (nonnull id<UICoordinateSpace>)coordinateSpace;
Swift
func tryToShowAnnotationMenu(at point: CGPoint, in coordinateSpace: UICoordinateSpace) -> Bool
Parameters
point
Location of touch.
coordinateSpace
Coordinate space of
point
.Return Value
true
if the attempt to show an annotation creation/pasting menu succeeded as the result of calling this method, otherwisefalse
. -
Component responsible for performing fast scroll.
This component is backed by a tap gesture recognizer. This component provides an additional activation context that contains information about the direction of fast scroll.
You can take advantage of component activation conditions to allow or disallow fast scroll based on the given context and location. For example, to only allow forward fast scroll, you can write:
fastScroll.addActivationCondition { context, _, _ in context.direction == .forward }
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<PSPDFFastScrollContext *> *_Nonnull fastScroll;
Swift
var fastScroll: InteractionComponent<FastScrollContext> { get }
-
Attempts to perform fast scroll at the given location.
Note
This method will respect the activation conditions of
fastScroll
interaction component but it will ignore itsenabled
property.Declaration
Objective-C
- (BOOL)tryToPerformFastScrollAtPoint:(CGPoint)point inCoordinateSpace: (nonnull id<UICoordinateSpace>)coordinateSpace;
Swift
func tryToPerformFastScroll(at point: CGPoint, in coordinateSpace: UICoordinateSpace) -> Bool
Parameters
point
Location of touch.
coordinateSpace
Coordinate space of
point
.Return Value
true
if the attempt to perform fast scroll succeeded as the result of calling this method, otherwisefalse
. -
Component responsible for performing smart zoom.
This component is backed by a double tap gesture recognizer. This component provides an additional activation context that contains information about the target zoom rectangle and the scroll view which is being zoomed.
You can take advantage of component activation conditions to allow or disallow smart zoom based on the given context and location. For example, to disallow smart zoom on a certain page, you can write:
smartZoom.addActivationCondition { _, point, coordinateSpace in let containingPageView = visiblePageViews.first { pageView in let pointInPageView = pageView.convert(point, from: coordinateSpace) return pageView.bounds.contains(pointInPageView) } if let containingPageView { return containingPageView.pageIndex != 0 } else { return true } }
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<PSPDFSmartZoomContext *> *_Nonnull smartZoom;
Swift
var smartZoom: InteractionComponent<SmartZoomContext> { get }
-
Attempts to perform smart zoom at the given location.
Note
This method will respect the activation conditions of
smartZoom
interaction components but it will ignore itsenabled
property.Declaration
Objective-C
- (BOOL)tryToPerformSmartZoomAtPoint:(CGPoint)point inCoordinateSpace: (nonnull id<UICoordinateSpace>)coordinateSpace;
Swift
func tryToPerformSmartZoom(at point: CGPoint, in coordinateSpace: UICoordinateSpace) -> Bool
Parameters
point
Location of touch.
coordinateSpace
Coordinate space of
point
.Return Value
true
if the attempt to perform smart zoom succeeded as the result of calling this method, otherwisefalse
. -
Component responsible for beginning text selection.
This component is backed by several gesture recognizers, including long press, double tap and triple tap gesture recognizers. This component provides no additional activation context.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull selectText;
Swift
var selectText: InteractionComponent<NSNull> { get }
-
Component responsible for discarding text selection.
This component is backed by a tap gesture recognizer. This component provides no additional activation context.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull deselectText;
Swift
var deselectText: InteractionComponent<NSNull> { get }
-
Component responsible for toggling user interface.
This component is backed by a tap gesture recognizer. This component provides no additional activation context.
You can take advantage of component activation conditions to allow or disallow toggling user interface based on the provided location. For example, to only allow toggling user interface outside of visible spread views, you can write:
toggleUserInterface.addActivationCondition { _, point, coordinateSpace in documentViewController.visibleSpreadViews.allSatisfy { spreadView in let pointInSpreadView = spreadView.convert(point, from: coordinateSpace) return !spreadView.bounds.contains(pointInSpreadView) } }
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull toggleUserInterface;
Swift
var toggleUserInterface: InteractionComponent<NSNull> { get }
-
Attempts to toggle user interface at the given location.
Note
This method will respect the activation conditions of
toggleUserInterface
interaction component but it will ignore itsenabled
property.Declaration
Objective-C
- (BOOL)tryToToggleUserInterfaceAtPoint:(CGPoint)point inCoordinateSpace: (nonnull id<UICoordinateSpace>)coordinateSpace;
Swift
func tryToToggleUserInterface(at point: CGPoint, in coordinateSpace: UICoordinateSpace) -> Bool
Parameters
point
Location of touch.
coordinateSpace
Coordinate space of
point
.Return Value
true
if the attempt to toggle user interface succeeded as the result of calling this method, otherwisefalse
. -
A component composed of all other components:
selectAnnotation
,deselectAnnotation
,editAnnotation
,transformAnnotation
,openLinkAnnotation
,showAnnotationMenu
,fastScroll
,smartZoom
,selectText
,deselectText
andtoggleUserInterface
.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull allInteractions;
Swift
var allInteractions: InteractionComponent<NSNull> { get }
-
Component composed of other components related to annotations:
selectAnnotation
,deselectAnnotation
,editAnnotation
,transformAnnotation
,openLinkAnnotation
andshowAnnotationMenu
.You can take advantage of component activation conditions to allow or disallow all interactions with annotations based on the given location. For example, to disallow interacting in any way with annotations, you can write:
allAnnotationInteractions.isEnabled = false
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull allAnnotationInteractions;
Swift
var allAnnotationInteractions: InteractionComponent<NSNull> { get }
-
Component composed of other components related to text selection:
selectText
anddeselectText
.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInteractionComponent<NSNull *> *_Nonnull allTextInteractions;
Swift
var allTextInteractions: InteractionComponent<NSNull> { get }