Disable Scroll Bouncing in PDF using Swift for iOS

Disable bouncing for the document scroll view zoom and zoom view.


//
// Copyright © 2019-2025 PSPDFKit GmbH. All rights reserved.
//
// The Nutrient sample applications are licensed with a modified BSD license.
// Please see License for details. This notice may not be removed from this file.
//
import PSPDFKit
import PSPDFKitUI
class DisableScrollBouncingExample: Example, PDFDocumentViewControllerDelegate {
override init() {
super.init()
title = "Disable Scroll View Bouncing"
contentDescription = "Disable bouncing for the document scroll view zoom and zoom view"
category = .viewCustomization
}
override func invoke(with delegate: ExampleRunnerDelegate) -> UIViewController {
let document = AssetLoader.document(for: .welcome)
let controller = PDFViewController(document: document)
controller.documentViewController?.delegate = self
return controller
}
// MARK: PDFViewControllerDelegate
// Disables bouncing on the scroll view, even when fully zoomed out.
// Noticeable when scrolling to the left on the first page, or when scrolling to the right on the last page.
func documentViewController(_ documentViewController: PDFDocumentViewController, configureScrollView scrollView: UIScrollView) {
scrollView.bounces = false
}
// Disables bouncing when scrolling while zoomed in.
func documentViewController(_ documentViewController: PDFDocumentViewController, configureZoom zoomView: UIScrollView, forSpreadAt spreadIndex: Int) {
zoomView.bounces = false
}
}

This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.