我的目标是搜索一个字符串,然后转到它。我有实现它所需的这三行代码。我只知道我实现这一目标的思维过程遗漏了一些东西。我不知道如何使用.findstring。我读到它返回一个 PDFSelections 数组。但我不确定如何使用.setCurrentSelectionPDFSelection 数组来使用它。
let found = document.findString(selection, withOptions: .caseInsensitive)
let stringSelection = page?.selection(for: NSRange(location:10, length:5))
pdfView.setCurrentSelection(stringSelection, animate: true)
Run Code Online (Sandbox Code Playgroud)