在阅读文档时保存用户进度。迅速

我有一张带有pdf文档的表格。打开文档后,用户将切换到具有自定义类(PDFView)的视图。

有必要单击按钮保存最后一个阅读用户文档的地方。

查看读取文档的控制器代码。

import UIKit
import PDFKit

var nameFile:String?
var titleChapter:String?
class pdfView: UIViewController {


    //save progress doc
    @IBaction func SaveScrollaction(_ sender: UIBarButtonItem)
    {
        let  dest =   pdfDocView.currentDestination
    pdfDocView.go(to: dest!)

    }
    //Pdf view
    @IBOutlet var pdfDocView: PDFView!
    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationItem.title = titleChapter
        navigationController?.navigationBar.barTintColor = #colorLiteral(red: 0.5326591512,green: 0,blue: 0.002649205323,alpha: 0.8)

        //name Documents for view
        if let path = Bundle.main.path(forResource: nameFile,ofType:"pdf") {
            if let pdfDocument = PDFDocument(url: URL(fileURLWithPath: path)) {
                pdfDocView.displayMode = .singlePageContinuous
                pdfDocView.autoScales = true
                pdfDocView.displayDirection = .vertical
                pdfDocView.document = pdfDocument
            }

        }

    }

}
sagaxu 回答:在阅读文档时保存用户进度。迅速

我相信您可以使用属性currentDestination,其中应包含当前页面和位置。要在PDFView中设置目标对象,请使用方法go(to destination: PDFDestination)

您可以使用常规存储解决方案保存对象。

Apple PDFKit Docs

本文链接:https://www.f2er.com/3064250.html

大家都在问