Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maximumPrimaryColumnWidth for NavigationSplitView always resets on iOS 18 #449

Open
2 tasks done
fguerrero-e opened this issue Mar 5, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@fguerrero-e
Copy link

Description

Hello,
I'm working on updating a project from using NavigationView into the new NavigationSplitView and NavigationStack since the min deployment iOS has been bumped to iOS 16. I encountered an issue when trying to change the default width of the sidebar of a NavigationSplitView in a 2 columns setup (aka the Master View). The property maximumPrimaryColumnWidth during the .instrospect block is always reseted only on iOS 18 (default value: -3.4028234663852886e+38) which forces me to set this property every time instead of just once as I had it before. Even so, when showing a sheet, you can see in the back the sidebar's width changing which doesn't look good (the property being reset is happening regardless of the sheet and the ObservableObject, you can confirm this with the print, this is just a setup to see the problem visually).
Please advise if this is an issue with the library or if I should raise it to Apple (since they're always changing the SwiftUI components every release...)
Below I put the code from a new project with SwiftUIIntrospect 1.3.0 installed through Cocoapods.

Checklist

Expected behavior

NavigationSplitView.iOS.17.mov

Actual behavior

NavigationSplitView.iOS.18.mov

Steps to reproduce

import SwiftUI
import SwiftUIIntrospect

@main
struct testApp: App {
    @ObservedObject var vm = VM()
    var body: some Scene {
        WindowGroup {
            NavigationSplitView {
                Button("Side") {
                    vm.show = true
                }
            } detail: {
                Text("Detail")
            }
            .introspect(.navigationSplitView, on: .iOS(.v16, .v17, .v18)) { (splitViewController: UISplitViewController) in
                print("MAX " + splitViewController.maximumPrimaryColumnWidth.description)
                print("MIN " + splitViewController.minimumPrimaryColumnWidth.description)
                print("FRACTION " + splitViewController.preferredPrimaryColumnWidthFraction.description)
                splitViewController.preferredPrimaryColumnWidthFraction = 0.40
                let minimumWidth = min(splitViewController.view.bounds.width,splitViewController.view.bounds.height)
                splitViewController.minimumPrimaryColumnWidth = minimumWidth / 2
                splitViewController.maximumPrimaryColumnWidth = minimumWidth
            }
            .sheet(isPresented: $vm.show) {
                Text("sheet")
            }
        }
    }
}

class VM: ObservableObject {
    @Published var show = false
}

Version information

1.3.0

Destination operating system

iOS 18

Xcode version information

16.2

Swift Compiler version information

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: x86_64-apple-macosx15.0
@fguerrero-e fguerrero-e added the bug Something isn't working label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant