PSPDFViewState


@interface PSPDFViewState : PSPDFModel <NSSecureCoding>

Represents a certain view state (document position, zoom) of a PSPDFDocument.

Note

Prior to PSPDFKit 8 for iOS, if an instance of this class had a viewPort, that view port was defined in raw PDF coordinates (not considering page rotation or CropBox). The view port is now defined in normalized PDF coordinates. Instances created from old archives may contain unexpected view ports, but PSPDFKit will automatically apply the page transform when such an instance is applied to a view.
  • Designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex
                                     viewPort:(CGRect)viewPort
                               selectionState:
                                   (nullable PSPDFSelectionState *)selectionState;

    Swift

    init(pageIndex: PageIndex, viewPort: CGRect, selectionState: PSPDFSelectionState?)
  • Initializes a PSPDFViewState with the specified page index and selection state only. The view port will be set to CGRectNull.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex
                               selectionState:
                                   (nullable PSPDFSelectionState *)selectionState;

    Swift

    convenience init(pageIndex: PageIndex, selectionState: PSPDFSelectionState?)
  • Initializes a PSPDFViewState with the specified page index and view port only. The selection state will be set to nil.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex
                                     viewPort:(CGRect)viewPort;

    Swift

    convenience init(pageIndex: PageIndex, viewPort: CGRect)
  • Initializes a PSPDFViewState with a page index only. The view port and selection state will be set to CGRectNull and nil respectively.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(PSPDFPageIndex)pageIndex;

    Swift

    convenience init(pageIndex: PageIndex)
  • Visible Page.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFPageIndex pageIndex;

    Swift

    var pageIndex: PageIndex { get }
  • The effectively visible rectangle of the page in page coordinates — 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 view–port. 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 (readonly, nonatomic) CGRect viewPort;

    Swift

    var viewPort: CGRect { get }
  • Whether or not the receiver has a restorable view port.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL hasViewPort;

    Swift

    var hasViewPort: Bool { get }
  • The view’s selection state.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFSelectionState *selectionState;

    Swift

    var selectionState: PSPDFSelectionState? { get }
  • Compares the receiver to another viewstate, 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: PSPDFViewState?, withAccuracy leeway: CGFloat) -> Bool

    Parameters

    other

    The object to compare to — may be nil.

    leeway

    How much each dimension of the viewport may differ.