Sunday, October 15, 2023
HomeiOS Developmentios - Programmatically Collapse NavigationSplitView to One Column

ios – Programmatically Collapse NavigationSplitView to One Column


I’ve developed a SwiftUI NavigationSplitView app with two columns and it really works as anticipated.
I’ve chosen dynamic fonts and crafted the visible parts to reply to person settings
for visible accessibility. I do know that plenty of the customers who will make use of this app could have
the font dimension set to the most important out there. Whereas that enhances their view of the element
display screen, it just about makes the sidebar unreadable. I am looking for a approach to change
the app’s conduct primarily based on the dimensions of the dynamic sort. Particularly, I would wish to have
the iPad conduct the identical as an iPhone conduct primarily based on a font dimension that I outline.
As it’s, the app on an iPhone collapses to a single column. I’ve not been in a position to
discover a approach to programmatically do that on an iPad.

I’ve tried:

Setting the horizontalSizeClass and as anticipated, it is a getter solely.
.horizontalSizeClass = .compact

I’ve tried setting the column width of the element to 0.
.navigationSplitViewColumnWidth(0)
that doesn’t work

I’ve tried utilizing the previous stack operate.
.navigationViewStyle(StackNavigationViewStyle())
that doesn’t work.

Clearly, this may be carried out, since it’s automated when the system is an iPhone. I assume
I might create two views – one stacked and one break up and select primarily based on a State variable
however that appears a bit crude.

Any steering can be appreciated. Xcode 14 beta 6, iOS 16



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments