Questions tagged [swiftui-navigationstack]

For questions about SwiftUI's NavigationStack, a view that displays a root view and enables you to present additional views over the root view.

Filter by
Sorted by
Tagged with
2 votes
1 answer
3k views

SwiftUI NavigationStack Navigation

I'm trying to use NavigationStack for Navigation for my SwiftUI Project. I have 4 Screens in total. The Main Page of my App has Login and Sign up Buttons. If the user signs in successfully the App ...
Amey079's user avatar
  • 121
2 votes
1 answer
903 views

SwiftUI NavigationStack NavigationLink same Value, multiple destinations

I have a model like so... struct User: Codable { let followersCount: Int let followingCount: Int } Using NavigationStack I would like to be able to use NavigationLink based on Value ...
Dan's user avatar
  • 603
2 votes
1 answer
1k views

NavigationStack Searchable .focused

I need to configure when the user clicks in the Search box to fulfill the condition (display another View). Once he clicks Cancel to display the original view (which can already be tested via ....
Aleš Slabý's user avatar
2 votes
1 answer
1k views

Remove background from NavigationStack in SwiftUI

In my app, I want to construct a single background view under my NavigationStack and then show that same background underneath other views that I navigate to via NavigationLinks. I am trying to do ...
Brandon Slaght's user avatar
2 votes
3 answers
2k views

SwiftUI NavigationLink isActive Binding Not Updated/Working

I have the following: @State private var showNext = false ... NavigationStack { VStack { NavigationLink(destination: NextView(showSelf: $showNext), ...
meaning-matters's user avatar
2 votes
1 answer
88 views

SwiftUI: NavigationPath always empty

The issue I'm facing is that my NavigationPath is always empty. The context is that I have 3 Views. View A contains the NavigationStack and has two NavigationLinks, to View B and View C respectively. ...
Patrick Ciurea's user avatar
2 votes
1 answer
379 views

View presented by navigationDestination:isPresented is always top of the navigation stack

When a view is pushed to the stack via navigationDestination:isPresented, it is always the top view in the stack, even if another view is pushed afterward. Is that the expected behaviour? In the ...
kluver's user avatar
  • 418
2 votes
1 answer
1k views

Why NavigationStack's navigationDestination is not called when part of VStack?

NavigationStack .navigationDestination() is not called if the navigation stack is a child of another container. The navigation happens visually but it only pushes to the stack a view with the typical ...
Fawkes's user avatar
  • 3,901
2 votes
1 answer
895 views

How to popToRoot with the new iOS 16 NavigationStack inside a TabView?

I would like to be able to popToRoot from my first tabItem (when im on page2 (from first tabItem) and tap twice on first tabItem when im on second tabItem) without having to use the NavigationViewKit ...
Flincorp's user avatar
  • 871
2 votes
1 answer
479 views

How to use the new NavigationStack for navigation in SwiftUI 4+ (iOS 16+)

I've read the documentation on the topic and I believe I have a basic understanding of it. In theory, it sound pretty good, and not too complex. If i have a model class ModelClass and a view to ...
Tommmy's user avatar
  • 23
2 votes
1 answer
297 views

Unexpected transitions when I add and remove screens from NavigationStack’s path at the same time

I’m using a NavigationStack and I’m dealing with the path programmatically, so I’m always the one appending and removing entries from it to control navigation. Any time I add or remove views from the ...
Fred Porciúncula's user avatar
2 votes
1 answer
1k views

SwiftUI - NavigationStack not working as expected

For some reason, my NavigationStack is bugging out when clicking through. I have changed NavigationView -> NavigationStack by it seems to be more complicated than anticipated and would greatly ...
DogDogDog's user avatar
2 votes
1 answer
286 views

Why is iOS16's NavigationLink disabled?

I am currently trying to use iOS16's NavigationLink to show detail views for my list items, but for some reason the items seem to be disabled - does anyone know why this is happening? NavigationLink(...
Mitemmetim's user avatar
2 votes
1 answer
771 views

Why are objects still in memory after emptying NavigationStack path?

I'm trying to implement a Coordinator for managing a flow. The state is stored inside the CoordinatorStore. There are 2 @Published properties for managing the flow. The screen property controls which ...
hydro1337x's user avatar
2 votes
1 answer
643 views

Does anybody have a working NavigationSplitView with NavigationStack in Details View?

No matter how it is set up, a complex 3 Columns NavigationSplitView with NavigationStack crashes or has inconsistent workflow. Sidebar selection determines which content (or feature) is in Content. ...
GeorgeJ's user avatar
  • 186
2 votes
1 answer
690 views

SWIFTUI - IOS 16 VideoPlayer AVplayer Autoplay stops working when doing any $Binding. How to fix?

I am using SWIFTUI for iOS 16 project, I have 2 view: ContentView (It has inside a regular NavigationStack with path binding) TeaserView (It a full screen video that I want it to autoplay the moment ...
Pro Girl's user avatar
  • 882
2 votes
1 answer
1k views

SwiftUI - NavigationStack opening same view multiple times

I am fairly new to iOS development and have been experimenting with SwiftUI for a bit. I am stuck for a while with list navigation and can't seem to fix the issue in any way. Here is what I've done: ...
Danail Alexiev's user avatar
2 votes
0 answers
106 views

Programmatic Routing in SwiftUI for TabView

I'm working on a SwiftUI application that follows a navigation pattern similar to Instagram, with a TabView at the root and complex navigation paths starting from different tabs. I've set up my ...
faizy's user avatar
  • 624
2 votes
2 answers
490 views

SwiftData - using @Query with a filter predicate does not work as expected

I am using SwiftData & SwiftUI. This is the rough setup of my code: struct ListItemView: View { @Environment(\.modelContext) var modelContext @Query private var items: [Items] @...
Rajiv Nair's user avatar
2 votes
1 answer
198 views

Replace top view in NavigationStack

I have a fairly complex app that uses NavigationStack with several navigationDestinations. Things were working well until I got a request to have a button which replaces the current view with a new ...
P. Ent's user avatar
  • 1,733
2 votes
0 answers
237 views

Persist navigation paths in NavigationSplitView with NavigationStacks

I have an SwiftUI iOS app that uses TabView to display 4 different NavigationStacks. Each stack can be navigated into. To make this app work better on iPad OS I'd like to use a NavigationSplitView ...
Sebastian's user avatar
  • 2,905
2 votes
1 answer
180 views

In SwiftUI showing an AdMob Interstitial breaks NavigationLink objects - what am I doing wrong?

I have a simple app with a Home View, a Content View and a Settings View. I am trying to show an AdMob Interstitial when I navigate from the Home View to the Content View. The navigation between views ...
zBandit's user avatar
  • 21
2 votes
1 answer
284 views

Change NavigationStack-path from ViewModel?

I'm trying to implement the MVVM-architecture in my little app and I am confused about how to update the path of my NavigationStack from the ViewModel. My path is a @Published property and gets ...
J. Mann's user avatar
  • 135
2 votes
0 answers
414 views

NavigationStack push animation disappears after presenting a view with .sheet modifier

I need to present a view with .sheet modifier in NavigationStack. But the default push animation of NavigationStack will disappear if I present a view with .sheet modifier first. This is my code: ...
Rufus's user avatar
  • 650
2 votes
0 answers
369 views

NavigationSplitView detail not updating

Why does the button "Show second view" not work here? struct ContentView: View { @State private var showSecondView = false var body: some View { NavigationSplitView { ...
John's user avatar
  • 1,092
2 votes
0 answers
645 views

SwiftUI - NavigationStack: Why my NavigationPath() is printing the wrong path.count?

I have the following basic utilization of NavigationStack with SwiftUI for iOS 16, Xcode. The issues I am facing is that when I click back and printing the count, the root count is wrong and shows as &...
Pro Girl's user avatar
  • 882
2 votes
0 answers
866 views

Use NavigationStack + NavigationLink + .navigationDestination without Hashable conformation

Consider the following code, import SwiftUI class Product: Identifiable { let id = UUID() let title: String init(title: String) { self.title = title } } struct ContentView: ...
Adrian Föder's user avatar
2 votes
1 answer
890 views

A complex Navigation with NavigationPath in SwiftUI

The usual flow is the stack. Push views and pop views. My requirements is a bit complex and I did not find a way to do it in IOS 16. Let say we have a Cover page Contents page Details page Now, the ...
kelalaka's user avatar
  • 5,350
2 votes
0 answers
192 views

NavigationLink In NavigationStack is disabled

I wrote test code for NavigationStack. The behavior of the code is a two-step transition(ContentView -> SubsubTestView -> DetailView). But I got an error when I have selected a name in ...
tbt's user avatar
  • 459
2 votes
0 answers
306 views

Removing more than one view from NavigationStack is not animated

I noticed that removing more than 1 view from a NavigationStack (using .removeLast(k) on its NavigationPath, where k > 1) is not animated at all. I was expecting to see the previous view sliding ...
Paul Mielle's user avatar
2 votes
1 answer
1k views

SwiftUI Navigation Stack with Routes

I'm trying to create navigation for my app using Navigation Stack and routing. My code is functioning and navigating to views, the problem I'm having is that the view is getting called several times ...
steve lang's user avatar
2 votes
1 answer
273 views

SearchBar leads to warning. SwiftUI

I noticed that Xcode shows warning when a view has list with SearchBar and swipe down action leads to it. The warning message: [Assert] What changed the navigation bar bounds size to something ...
Alexander Khitev's user avatar
1 vote
2 answers
3k views

SwiftUI: Displaying the navigation bar using NavigationStack

I want to display a navigation bar having an orange background color and a title with white color. Everything works fine with this setup: let navigationBarAppearance = UINavigationBarAppearance() ...
iOSdeveloper's user avatar
1 vote
1 answer
691 views

NavigationStack inside TabView inside NavigationStack throws

I'm trying to migrate a coordinator pattern using UINavigationController into the new NavigationStack. The navigation flow is quite complex, but I've made a simple project to simplify it to this: ...
Marco Scabbiolo's user avatar
1 vote
1 answer
126 views

NavigationStack does not display a view on UI after appending a new path

I am using SwiftUI NavigationStack as a router in my application. I have a ParentView as an initial view with a button. When I click a button I want to show a loading view and when API answer is ...
ofun's user avatar
  • 63
1 vote
1 answer
369 views

NavigationStack programatically appending childviews with different types

I have a NavigationStack with parent view struct MainDatabaseView: View { @State private var path = NavigationPath() var body: some View { NavigationStack(path: $path) { List { ...
Petr Smejkal's user avatar
1 vote
1 answer
202 views

How can I make a NavigationTitle in SwiftUI open a picker view?

I understand that you can bind a string to the navigation title like: .navigationTitle($titleString) and you get: and this will allow you to rename it, but is there a way to bind this to an enum to ...
Halpo's user avatar
  • 3,044
1 vote
1 answer
96 views
+50

How to pass data to a sub View from a SwiftData query

I'm learning Swift through a project. I'm creating an app where the user can create multiple accounts and register transactions within each account. The models and views that are relevant to my ...
bluprince13's user avatar
  • 4,737
1 vote
1 answer
287 views

iOS SwiftUI ScrollView in NavigationStack: Scroll To Top Doesn't Finish Expanding Navigation Title, If Animated

I'm needing to implement a scroll-to-top button for a ScrollView living in a NavigationStack, but when I call proxy.scrollTo() (with proxy being the ScrollViewProxy provided by ScrollViewReader), the ...
Scott Muddlegeist's user avatar
1 vote
2 answers
286 views

navigationDestination was declared earlier on the stack

I'm running into an issue with .navigationDestination. When the user clicks the Calculate button, a new view opens with a list of the items. Then the user can click on a row and get more details. ...
koen's user avatar
  • 5,615
1 vote
1 answer
125 views

How to center views vertically as if there were no navigation title?

I have a NavigationStack/NavigationView which loads its links. When it's loading or contains no links, I want to display a view centered in the screen to inform the user. However, when there's a ...
David's user avatar
  • 15
1 vote
1 answer
790 views

Use NavigationPath across multiple views in SwiftUI

I'm new to Swift/SwiftUI, and I'm working with the NavigationStack view the programmatic way using a NavigationPath. Here is a part of my code: struct ContentView: View { @State private var ...
Giesburts's user avatar
  • 7,177
1 vote
2 answers
117 views

NavigationStack pushing too many views

Hello I am fairly new to swiftui and I am creating a NavigationStack from an array of items. Every item in the array is pushed into navigation when I click on the item (I have to click the back button ...
John Citrowske's user avatar
1 vote
1 answer
401 views

Bug with NavigationLink and @Binding properties causing unintended Interactions in the app

I've encountered a bug in SwiftUI that could cause unintended interaction with the app without the user's knowledge. Description The problem seems to be related to using @Binding properties on the ...
Hollycene's user avatar
  • 415
1 vote
1 answer
551 views

I cannot navigate deeper into the views in Swiftui

I have three views in my project - ContentView, SecondView, ThirdView I want to navigate from contentView to secondView and secondView to thirdView. ContentView :- import SwiftUI struct ContentView: ...
Uday Chaudhary's user avatar
1 vote
1 answer
36 views

Unwanted whitespace in Custom NavigationBar in SwiftUI

I have an unwanted white space in my custom SwiftUI NavigationBar, which I want gone. I played around with removing the paddings, but I don't get the wanted looks nor does that remove the white space. ...
Toni's user avatar
  • 13
1 vote
2 answers
117 views

What is the solution to this NavigationStack glitch?

I've encountered a strange glitch with NavigationStack when mixing the old-style NavigationLink with the new .navigationDestination style ones. While this example is trivial and easily fixed here, in ...
trapper's user avatar
  • 11.8k
1 vote
2 answers
117 views

How do I detect when I return to the root view of NavigationStack in SwiftUI?

How do I detect from the root view that I've returned back to the root view after navigating via NavigationLink to another view? .onAppear() is not triggering when I return back to the root view via ...
Matt's user avatar
  • 593
1 vote
1 answer
104 views

NavigationStack does not render if child view contains a conditional

I am trying to use SwiftUI's new NavigationStack/NavigationLink pattern but am running into an issue if the view I am navigating to has a conditional render (just a simple if statement) in it, it does ...
rosstafarian's user avatar
1 vote
2 answers
395 views

How to make NavigationStack work with Views and popToRoot in SwiftUI?

I'm trying to use NavigationStack with Views in SwiftUI, but I'm having trouble understanding its functionality. I have gone through several tutorials, but I still don't understand the purpose of the ...
acroisie's user avatar