PDFView 无法移动到下一页
PDFView unable to move to nextpage
代码:
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
}
}
我尝试在 app.it 中显示 pdf 文件正在工作 fine.how 以实现水平滚动(逐页)和搜索功能(如突出显示搜索词)features.any 帮助将是appericated.thanks提前
您需要添加这行代码:
pdfView.usePageViewController(true, withViewOptions: nil)
****更新**
PDFDocument。有一些关于搜索的通知。看看。
尝试使用此代码搜索 string.in 这一行 beginFindString 你可以设置字符串
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)
}
}
}
代码:
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
}
}
我尝试在 app.it 中显示 pdf 文件正在工作 fine.how 以实现水平滚动(逐页)和搜索功能(如突出显示搜索词)features.any 帮助将是appericated.thanks提前
您需要添加这行代码:
pdfView.usePageViewController(true, withViewOptions: nil)
****更新**
PDFDocument。有一些关于搜索的通知。看看。
尝试使用此代码搜索 string.in 这一行 beginFindString 你可以设置字符串
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)
}
}
}