PSPDFViewState
Objective-C
@interface PSPDFViewState : PSPDFModel
Swift
class PDFViewState : ModelObject
Represents a certain view state (document position, zoom) of a Document
.
Note
Prior to PSPDFKit 8 for iOS, if an instance of this class had aviewPort
, that viewport was defined in raw PDF coordinates (not
considering page rotation or CropBox). The viewport is now defined in normalized PDF coordinates. Instances created from old archives may
contain unexpected viewports, but PSPDFKit will automatically apply the page transform when such an instance is applied to a view.
-
The designated initializer.
Declaration
Objective-C
- (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex viewPort:(CGRect)viewPort selectionState: (nullable PSPDFSelectionState *)selectionState selectedAnnotationNames: (nullable NSArray<NSString *> *)selectedAnnotationNames;
Swift
init(pageIndex: PageIndex, viewPort: CGRect, selectionState: PSPDFSelectionState?, selectedAnnotationNames: [String]?)
-
Initializes a
PDFViewState
with the specified page index, viewport and selection state only.Declaration
Objective-C
- (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex viewPort:(CGRect)viewPort selectionState: (nullable PSPDFSelectionState *)selectionState;
Swift
convenience init(pageIndex: PageIndex, viewPort: CGRect, selectionState: PSPDFSelectionState?)
-
Initializes a
PDFViewState
with the specified page index and selection state only. The viewport will be set toCGRectNull
.Declaration
Objective-C
- (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex selectionState: (nullable PSPDFSelectionState *)selectionState;
Swift
convenience init(pageIndex: PageIndex, selectionState: PSPDFSelectionState?)
-
Initializes a
PDFViewState
with the specified page index and viewport only. The selection state will be set tonil
.Declaration
Objective-C
- (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex viewPort:(CGRect)viewPort;
Swift
convenience init(pageIndex: PageIndex, viewPort: CGRect)
-
Initializes a
PDFViewState
with a page index only. The viewport and selection state will be set toCGRectNull
andnil
respectively.Declaration
Objective-C
- (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex;
Swift
convenience init(pageIndex: PageIndex)
-
Visible Page.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFPageIndex pageIndex;
Swift
var pageIndex: PageIndex { get }
-
The effectively visible rectangle of the page in the PDF page coordinate space. This is
CGRectNull
if the view was fully visible and not displayed in continuous scrolling mode.Note
Due to the nature of continuous scrolling, even a fully zoomed out page can have a viewport. This is necessary to preserve a scrolling offset in documents where more than one page fits on the screen at once.Declaration
Objective-C
@property (nonatomic, readonly) CGRect viewPort;
Swift
var viewPort: CGRect { get }
-
Whether or not the receiver has a restorable viewport. This is false if the viewport is a null or infinite rectangle, or includes NaN values.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL hasViewPort;
Swift
var hasViewPort: Bool { get }
-
The view’s selection state.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFSelectionState *selectionState;
Swift
var selectionState: PSPDFSelectionState? { get }
-
Compares the receiver to another view state, allowing for the specified leeway if both have a viewport.
Declaration
Objective-C
- (BOOL)isEqualToViewState:(nullable PSPDFViewState *)other withAccuracy:(CGFloat)leeway;
Swift
func isEqual(to other: PDFViewState?, withAccuracy leeway: CGFloat) -> Bool
Parameters
other
The object to compare to — may be
nil
.leeway
How much each dimension of the viewport may differ.