Fix PDF navigator content inset on iOS 27 - #900
Merged
Merged
Conversation
Since iOS 27, PDFKit lays out pages inside the PDFView's bounds inset by its safeAreaInsets instead of the full bounds. In paginated mode this bypasses the scroll view's contentInset entirely, so neither contentInsetAdjustmentBehavior = .never nor zeroing contentInset prevented the content from shifting when the navigation bar was shown. PDFDocumentView now overrides safeAreaInsets to report the insets it already computes, so PDFKit lays the content out where the navigator asks. This also makes the pdfDocumentViewContentInset delegate hook effective in paginated mode on iOS 27, where it was previously ignored. This behavior is undocumented. It was identified by measuring where PDFKit places a page in a paginated PDFView inside a navigation controller, across three runtimes: with a 390x844 view, a 612x792 page and the nav bar shown, the page lands centered in the full bounds on iOS 18.6 (y=172.9) and 26.4 (y=172.9), but centered in the safe area on iOS 27.0 (y=204.9). The measurement is recorded in the code comment.
There was a problem hiding this comment.
🟡 Changes recommended
The modal reader’s dismissal button needs an accessibility label for VoiceOver users.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates the PDF navigator and Test App for iOS 27 compatibility, including safe-area handling and modal reader presentation.
Changes:
- Applies computed insets to PDFKit layouts.
- Migrates the Test App to scene-based lifecycle handling.
- Presents readers modally with dismissal controls.
- Adjusts preferences spacing and documents the fix.
File summaries
| File | Summary |
|---|---|
TestApp/Sources/SceneDelegate.swift |
Configures the scene window and handles publication URLs. |
TestApp/Sources/Reader/ReaderModule.swift |
Presents readers full-screen modally. Nit (2 votes): remove stale back-button setup. |
TestApp/Sources/Reader/Common/ReaderViewController.swift |
Adds reader dismissal control. Moderate (1 vote): provide a localized accessibility label. |
TestApp/Sources/Reader/Common/Preferences/UserPreferences.swift |
Adjusts SwiftUI row spacing. |
TestApp/Sources/Info.plist |
Registers the scene configuration. |
TestApp/Sources/AppDelegate.swift |
Initializes app state and scene configuration. |
Sources/Navigator/PDF/PDFDocumentView.swift |
Supplies computed safe-area insets to PDFKit. |
CHANGELOG.md |
Documents the PDF inset fix. |
Review details
Suppressed comments (1)
TestApp/Sources/Reader/Common/ReaderViewController.swift:59
- This is an image-only bar button with no accessibility label, so VoiceOver may expose it as an unlabeled button even though it is the only way to dismiss the newly modal reader. Use a localized system close item (or set an explicit localized
accessibilityLabel) so assistive-technology users can identify the action.
navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "xmark"), style: .plain, target: self, action: #selector(close))
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Various fixes for iOS 27:
PDFDocumentViewnow overridessafeAreaInsetsto report its own computed insets, since PDFKit's paginated mode bypassescontentInsetentirely on iOS 27.