How to use NavigationView{} without having a sidebar show up on iPadOS

Hello,
New iOS coder here! I am wondering if there is a way that I can use NavigationView without the iPad version of the app creating a sidebar. I am making an application that does not make since to have a sidebar on it.

Again, I'm a complete beginner so a detailed explanation would be much appreciated!

Peace!
Answered by BabyJ in 654966022
If you mean having only one view showing at a time, like on iPhone (not master-detail), then you can use StackNavigationViewStyle().

A navigation view style represented by a view stack that only shows a single top view at a time.

Use it like this as a modifier on the NavigationView:
Code Block Swift
NavigationView {
...
}
.navigationViewStyle(StackNavigationViewStyle())


Accepted Answer
If you mean having only one view showing at a time, like on iPhone (not master-detail), then you can use StackNavigationViewStyle().

A navigation view style represented by a view stack that only shows a single top view at a time.

Use it like this as a modifier on the NavigationView:
Code Block Swift
NavigationView {
...
}
.navigationViewStyle(StackNavigationViewStyle())


I don't think that's what I need, you see I want to make my NavigationView (That is the sidebar of iPad app and main of iPhone app) to be stretched out throughout the whole iPad screen.

OH, Whoops...

I didn't mean to mark this as answered.

Here is a new version of this thread: https://developer.apple.com/forums/thread/670533

How to use NavigationView{} without having a sidebar show up on iPadOS
 
 
Q