PSPDFSearchViewController
Objective-C
@interface PSPDFSearchViewController
: PSPDFBaseTableViewController <
UISearchDisplayDelegate, UISearchBarDelegate, PSPDFTextSearchDelegate,
PSPDFStyleable, PSPDFOverridable>
Swift
class SearchViewController : BaseTableViewController, UISearchDisplayDelegate, UISearchBarDelegate, TextSearchDelegate, Styleable, Overridable
The search view controller allows text and annotation searching within the current document. It notifies its delegate as results are loaded.
Usually this is presented as a popover, but it also works modally.
-
The class of the table view cell that is used to represent a search result.
This method can be overridden to return a different class. The returned class has to be a subclass of
UITableViewCell
and needs to conform toPSPDFSearchResultViewable
.In order to properly layout the table view, any instance of the returned class needs to be resizable with auto layout.
Note
This method has to return a single class. Making the return value of this method dynamically return different classes in any way results in undefined behavior.
Declaration
Objective-C
+ (nonnull Class<PSPDFSearchResultViewable>)resultCellClass;
Swift
class func resultCellClass() -> SearchResultViewable.Type
Return Value
A class object of the class that should be used to represent a single search result in the table view.
-
The class of the table view section header that is used to represent the scope of the current result section.
The method can be overridden to return a different class. The returned class has to be a subclass of
UITableViewHeaderFooterView
and needs to conform toPSPDFSearchScopeViewable
.A scope currently is only represented in the UI if the search view controller’s
searchVisiblePagesFirst
returnstrue
.In order to properly layout the table view, any instance of the returned class needs to be resizable with auto layout.
Note
This method has to return a single class. Making the return value of this method dynamically return different classes in any way results in undefined behavior.
Declaration
Objective-C
+ (nonnull Class<PSPDFSearchScopeViewable>)scopeHeaderClass;
Swift
class func scopeHeaderClass() -> SearchScopeViewable.Type
Return Value
A class object of the class that should be used to represent the scope of the current section of results.
-
The class of the table view section footer that is used to represent the search status.
The method can be overridden to return a different class. The returned class has to be a subclass of
UITableViewHeaderFooterView
and needs to conform toPSPDFSearchStatusViewable
.A status currently is only represented in the UI if it is not idle (i.e. if the search has already been started).
In order to properly layout the table view, any instance of the returned class needs to be resizable with auto layout.
Note
This method has to return a single class. Making the return value of this method dynamically return different classes in any way results in undefined behavior.
Declaration
Objective-C
+ (nonnull Class<PSPDFSearchStatusViewable>)statusFooterClass;
Swift
class func statusFooterClass() -> SearchStatusViewable.Type
Return Value
A class object of the class that should be used to represent the status of the current search in the table view.
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
-
Designated initializer.
Declaration
Objective-C
- (nonnull instancetype)initWithDocument:(nullable PSPDFDocument *)document;
Swift
init(document: PSPDFDocument?)
-
The current document.
Declaration
Objective-C
@property (nonatomic, nullable) PSPDFDocument *document;
Swift
var document: PSPDFDocument? { get set }
-
The search view controller delegate.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFSearchViewControllerDelegate> _Nullable delegate;
Swift
@IBOutlet weak var delegate: SearchViewControllerDelegate? { get set }
-
Current searchText. If set before showing the controller, keyboard will not be added.
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *searchText;
Swift
var searchText: String? { get set }
-
Different behavior depending on size classes.
Declaration
Objective-C
@property (nonatomic) BOOL showsCancelButton;
Swift
var showsCancelButton: Bool { get set }
-
Search bar for controller.
Warning
You can change attributes (e.g.barStyle
) but don’t change the searchBar delegate.Declaration
Objective-C
@property (nonatomic, readonly) UISearchBar *_Nonnull searchBar;
Swift
var searchBar: UISearchBar { get }
-
Current search status. KVO observable.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFSearchStatus searchStatus;
Swift
var searchStatus: SearchViewController.Status { get }
-
Clears highlights when controller disappears. Defaults to NO.
Declaration
Objective-C
@property (nonatomic) BOOL clearHighlightsWhenClosed;
Swift
var clearHighlightsWhenClosed: Bool { get set }
-
Defaults to 600. A too high number will be slow.
Declaration
Objective-C
@property (nonatomic) NSUInteger maximumNumberOfSearchResultsDisplayed;
Swift
var maximumNumberOfSearchResultsDisplayed: UInt { get set }
-
Set to enable searching on the visible pages, then all. Defaults to NO. If not set, the natural page order is searched.
Declaration
Objective-C
@property (nonatomic) BOOL searchVisiblePagesFirst;
Swift
var searchVisiblePagesFirst: Bool { get set }
-
Number of lines to show preview text. Defaults to 2.
Declaration
Objective-C
@property (nonatomic) NSUInteger numberOfPreviewTextLines;
Swift
var numberOfPreviewTextLines: UInt { get set }
-
Searches the outline for the most matching entry, displays e.g. “Section 100, Page 2” instead of just “Page 2”.
Defaults to
false
.Note
This option can potentially invoke expensive outline parsing. Be sure to test search within your documents for performance issues with this option enabled.Declaration
Objective-C
@property (nonatomic) BOOL useOutlineForPageNames;
Swift
var useOutlineForPageNames: Bool { get set }
-
The last search result is restored in
viewWillAppear:
if the document UID matches the last used one. This search result is only persisted in memory. Defaults to YES.Note
Needs to be set before the view controller is presented to have an effect.Declaration
Objective-C
@property (nonatomic) BOOL restoreLastSearchResult;
Swift
var restoreLastSearchResult: Bool { get set }
-
Will include annotations that have a matching type into the search results. (contents will be searched). Defaults to PSPDFAnnotationTypeAll&~PSPDFAnnotationTypeLink.
Note
Requires theFeatures.annotationEditing
feature flag.Declaration
Objective-C
@property (nonatomic) PSPDFAnnotationType searchableAnnotationTypes;
Swift
var searchableAnnotationTypes: Annotation.Kind { get set }
-
Determines the search bar positioning/visibility. Defaults to
PSPDFSearchBarPinningAuto
.Declaration
Objective-C
@property (nonatomic) PSPDFSearchBarPinning searchBarPinning;
Swift
var searchBarPinning: SearchViewController.SearchBarPinning { get set }
-
Internally used
PSPDFTextSearch
object. (is a copy of the PSPDFTextSearch class in document)Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFTextSearch *textSearch;
Swift
var textSearch: TextSearch? { get }
-
Call to force a search restart. Useful if the underlying content has changed.
-
Called every time the text in the search bar changes.
Declaration
Objective-C
- (void)filterContentForSearchText:(nonnull NSString *)searchText scope:(nullable NSString *)scope;
Swift
func filterContent(forSearchText searchText: String, scope: String?)
-
Will update the status and insert/reload/remove search rows
Declaration
Objective-C
- (void)setSearchStatus:(PSPDFSearchStatus)searchStatus updateTable:(BOOL)updateTable;
Swift
func setSearchStatus(_ searchStatus: SearchViewController.Status, updateTable: Bool)
-
Returns the searchResult for a cell.
Declaration
Objective-C
- (nonnull PSPDFSearchResult *)searchResultForIndexPath: (nonnull NSIndexPath *)indexPath;
Swift
func searchResult(for indexPath: IndexPath) -> SearchResult
-
Will return a search bar. Called during
viewDidLoad
. Use to customize the toolbar. This method does basic properties liketintColor
,showsCancelButton
andplaceholder
. After calling this, the delegate will be set to this class.Declaration
Objective-C
@property (nonatomic, readonly) UISearchBar *_Nonnull createSearchBar;
Swift
var createSearchBar: UISearchBar { get }
-
Currently loaded search results.
Declaration
Objective-C
@property (nonatomic, readonly) NSArray<PSPDFSearchResult *> *_Nonnull searchResults;
Swift
var searchResults: [SearchResult] { get }