Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

646
Vistas
Cómo detectar el desplazamiento a otra página en PDF usando PDFkit

Estoy tratando de agregar el número de página actual para que cuando el usuario se desplace a otra página se muestre, por ejemplo, 2 de 3 (si el pdf tiene 3 páginas)

por ahora, uso este código

mostrará siempre 1 de 3

Creo que PDFkit usa UIScrollView, por lo que necesito llegar a ScrollView de esa manera que podría detectar cuando me desplazo a otra página y luego aumentar el número de página actual

No encontré ninguna forma de llegar a la vista de desplazamiento en PDFkit

 func showCurrentPageIndex(){ guard let totalPages = pdfContainerView.document?.pageCount else {return} guard let currentPage = pdfContainerView.currentPage else {return} guard let currentPageRef = currentPage.pageRef else {return} let pageIndex = currentPageRef.pageNumber totalPageNumbers.text = "\(totalPages)" currentPageIndex.text = "\(pageIndex)" }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Utilice una notificación ( PDFViewPageChanged ).

 import UIKit import PDFKit class ViewController: UIViewController, PDFViewDelegate { // MARK: - Variables var totalCount = Int() // MARK: - IBOutlet @IBOutlet weak var pdfView: PDFView! // MARK: - Life cycle override func viewDidLoad() { super.viewDidLoad() let filePath = "Some file document path" pdfView.document = getDocument(path: filePath) if let total = pdfView.document?.pageCount { totalCount = total } pdfView.backgroundColor = .lightGray pdfView.autoScales = true pdfView.displayMode = .singlePageContinuous pdfView.usePageViewController(true, withViewOptions: nil) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) /* notification */ NotificationCenter.default.addObserver (self, selector: #selector(handlePageChange), name: Notification.Name.PDFViewPageChanged, object: nil) } func getDocument(path: String) -> PDFDocument? { let pdfURL = URL(fileURLWithPath: filePath) let document = PDFDocument(url: pdfURL) return document } }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda