Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios PDFView无法移动到下一页_Ios_Swift_Pdf_Ios Pdfkit - Fatal编程技术网

Ios PDFView无法移动到下一页

Ios PDFView无法移动到下一页,ios,swift,pdf,ios-pdfkit,Ios,Swift,Pdf,Ios Pdfkit,代码: 我尝试在应用程序中显示pdf文件。它工作正常。如何实现水平滚动(逐页)和搜索功能(如突出显示搜索词)。将显示任何帮助。提前感谢您需要添加这行代码: if let path = Bundle.main.path(forResource: "test", ofType: "pdf") { let url = URL(fileURLWithPath: path) if let pdfDocument = PDFDocument(url: url)

代码:


我尝试在应用程序中显示pdf文件。它工作正常。如何实现水平滚动(逐页)和搜索功能(如突出显示搜索词)。将显示任何帮助。提前感谢您需要添加这行代码:

if let path = Bundle.main.path(forResource: "test", ofType: "pdf") {
            let url = URL(fileURLWithPath: path)
            if let pdfDocument = PDFDocument(url: url) {
                pdfView.displayMode = .singlePage
                pdfView.autoScales = true
                pdfView.displayDirection = .horizontal
                pdfView.document = pdfDocument
            }
        }
****更新**


。有一些关于搜索的通知。请看。

尝试使用此代码搜索字符串。在这一行中,可以设置beginFindString

pdfView.usePageViewController(true, withViewOptions: nil)

谢谢,它工作正常。对不起,我没有足够的声誉来支持你。对搜索功能有什么想法?你说的搜索功能是什么意思?比如移动到特定页面或突出显示匹配的单词,比如word Document这里是什么searchedItem?将searchedItem更改为SearchedStringDocumentDiEndDocument,documentDidFindMatch方法未被调用PLS委托您的PDFviewned设置pdfview.delegate=self?
var searchedString: PDFSelection?
override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
        self.document?.beginFindString("StringName", withOptions: .caseInsensitive)        
}

func documentDidEndDocumentFind(_ notification: Notification) {
    pdfView.setCurrentSelection(searchedString, animate: true)
}

func documentDidFindMatch(_ notification: Notification) {
    if let selection = notification.userInfo?.first?.value as? PDFSelection {
        selection.color = .Red
        if searchedString == nil {
            // The first found item sets the object.
            searchedString = selection
        } else {
            // All other found selection will be nested
            searchedString!.add(selection)
        }
    }
}