Revealed on: Could 21, 2024
By default, a NavigationSplitView
in SwiftUI will present customers an choice to toggle the visibility of the sidebar. If you wish to forestall this button from exhibiting up in order that customers will all the time should see your sidebar, you are able to do this by making use of the toolbar(eradicating:)
view modifier to your break up view’s sidebar as follows:
NavigationSplitView(sidebar: {
ExercisesList()
.toolbar(eradicating: .sidebarToggle)
}, element: {
ExerciseDetail(train: workouts.first!)
})
The draw back of doing that is that the button is hidden each in portrait and panorama modes. The result’s that panorama customers can not entry your app’s sidebar.
To repair this you possibly can attempt making use of the view modifier conditionally primarily based on the system’s orientation however that is not best; apps in panorama may additionally present the break up view as a single column. I’ve but to discover a good, dependable answer to conditionally presenting and hiding the sidebar toggle.
One upside for customers is that they’ll nonetheless summon the sidebar in portrait mode by swiping from the forefront of the display screen in the direction of the center. It is not excellent, but it surely’s higher than nothing I suppose.