PSPDFTextSelectionView


@interface PSPDFTextSelectionView : UIView <AVSpeechSynthesizerDelegate>

Handles text and image selection.

Note

Requires the PSPDFFeatureMaskTextSelection feature flag. Don’t manually create this class. The initializer here is not exposed. The selection color is determined by the tintColor property inherited from UIView.
  • The text selection delegate.

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        id<PSPDFTextSelectionViewDelegate> _Nullable delegate;

    Swift

    weak var delegate: PSPDFTextSelectionViewDelegate? { get set }
  • Currently selected glyphs.

    Note

    Use sortedGlyphs: to pre-sort your glyphs if you manually set this.

    Warning

    This method expects glyphs to be sorted in reading order.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, null_resettable)
        NSArray<PSPDFGlyph *> *selectedGlyphs;

    Swift

    var selectedGlyphs: [PSPDFGlyph]! { get set }
  • Currently selected text. Set via setting selectedGlyphs. Use discardSelection to clear.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *selectedText;

    Swift

    var selectedText: String? { get }
  • Currently selected image.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) PSPDFImageInfo *selectedImage;

    Swift

    var selectedImage: PSPDFImageInfo? { get set }
  • The selection alpha value. Defaults to UIColor.pspdf_selectionAlpha.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat selectionAlpha;

    Swift

    var selectionAlpha: CGFloat { get set }
  • Currently selected text, optimized for searching

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *trimmedSelectedText;

    Swift

    var trimmedSelectedText: String? { get }
  • To make it easier to select text, we slightly increase the frame margins. Defaults to 4 pixels.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat selectionHitTestExtension;

    Swift

    var selectionHitTestExtension: CGFloat { get set }
  • An NSArray of boxed CGRects for every selected block, in view coordinates.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSArray<NSValue *> *_Nonnull selectionRects;

    Swift

    var selectionRects: [NSValue] { get }
  • The rect (in view coordinates) for the first block that is currently selected, or CGRectZero if nothing is selected. Note that this will return the rect for a selected image too. Using this property is much quicker than doing selectionRects.firstObject.CGRectValue.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect rectForFirstBlock;

    Swift

    var rectForFirstBlock: CGRect { get }
  • The rect (in view coordinates) for the last block that is currently selected, or CGRectZero if nothing is selected. Note that this will return the rect for a selected image too. Using this property is much quicker than doing selectionRects.lastObject.CGRectValue.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect rectForLastBlock;

    Swift

    var rectForLastBlock: CGRect { get }
  • Updates the UIMenuController if there is a selection. Returns YES if a menu is displayed.

    Declaration

    Objective-C

    - (BOOL)updateMenuAnimated:(BOOL)animated;

    Swift

    func updateMenu(animated: Bool) -> Bool
  • Update the selection (text menu).

    Note

    animated is currently ignored.

    Declaration

    Objective-C

    - (void)updateSelectionAnimated:(BOOL)animated;

    Swift

    func updateSelection(animated: Bool)
  • Clears the current selection.

    Declaration

    Objective-C

    - (void)discardSelectionAnimated:(BOOL)animated;

    Swift

    func discardSelection(animated: Bool)
  • Required if glyph frames change.

    Declaration

    Objective-C

    - (void)clearCache;

    Swift

    func clearCache()
  • Currently has a text/image selection?

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL hasSelection;

    Swift

    var hasSelection: Bool { get }
  • Debugging feature, visualizes the text blocks.

    Declaration

    Objective-C

    - (void)showTextFlowData:(BOOL)show animated:(BOOL)animated;

    Swift

    func showTextFlowData(_ show: Bool, animated: Bool)