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.
289
questions
1
vote
1
answer
158
views
Change NavigationSplitView to NavigationStack
In the Food Truck app Apple Food Truck App the contentView has a NavigationSplitView to target iPadOS.
NavigationSplitView {
Sidebar(selection: $selection)
} detail: {
...
1
vote
1
answer
286
views
SwiftUI NavigationStack "Back" Localization
I'm facing some problems with a SwiftUI NavigationStack and the "Back"-button that appears automatically in the upper left corner of the screen.
Even in a very simple application the ...
1
vote
1
answer
306
views
SwiftUI NavigationStack: Unexpected Navigation Behavior from List View
I'm building an iOS app with SwiftUI and am encountering unexpected behaviour when navigating from a List view to a detail view.
I have three views: ViewA, ViewB, and ViewC. ViewA navigates to ViewB, ...
1
vote
2
answers
318
views
SwfitUI: Use .blur cause navigation title overlap with safe area
Edit: This seems fixed in iOS 17
I want to blur the app when it's in the background so I have this in my TestApp.swift
import SwiftUI
@main
struct TestApp: App {
@Environment(\.scenePhase) var ...
1
vote
1
answer
709
views
SwiftUI - NavigationBar not animated on Push when there is no or empty title in the root view of a NavigationStack
I'm experiencing an issue with the NavigationBar in SwiftUI where it doesn't animate when Detail View is pushed and there is no or empty [navigation] title in the root view of a NavigationStack.
Here ...
1
vote
1
answer
270
views
SwiftUI - Unable to navigate to next View from List/NavigationLink with navigationDestination
My first View represents a login screen, which then takes you to the home View. I've read through the documentation and watched WWDC22 - The SwiftUI cookbook for navigation which got me on the right ...
1
vote
2
answers
609
views
NavigationStack is breaking binding
I recently tried to migrate from SwiftUI NavigationView to NavigationStack, but experienced some problems with bindings. If the view stack has changes, my bindings seem to convert into some sort of ...
1
vote
1
answer
578
views
How to use NavigationLink outside of NavigationStack?
I have a safe area inset view that is placed on my NavigationStack so that acts as a bottom bar across all pushed views. However, in the safe area inset view, there are button which I'd like to push ...
1
vote
1
answer
155
views
NavigationStack failing to show the correct view hierarchy after pushing value from other tab
I have a bug in my application so I decided to create a self-contained example for the sake of being simple, which reproduces the problem.
I have a content view with two tabs: contacts and users:
...
1
vote
1
answer
133
views
SwiftUI Half-swipe back from navigation causes error
I noticed issue in SwiftUI when using NavigationStack
Once I swipe-back on a half and revert it -> it stops working
Also I attached sample code if you want to try it
import SwiftUI
struct ...
1
vote
1
answer
368
views
NavigationStack pushing new View issue with @Published
Weird issue using new NavigationStack. When trying to push the DrinkView for the second time, it's pushed twice and the OrderFood gets view removed from the navigation.
The reason is @Published var ...
1
vote
2
answers
45
views
Button inside NavigationLink that's inside a list item not working correctly
I have a button that I would like to link to another view upon clicking on it. I was told to put it inside a NavigationLink, use .borderless button style, but it activates outside of its area on the ...
1
vote
0
answers
74
views
How to properly manage view focus while pushing multiple views to NavigationStack path in SwiftUI iOS 17+
I'm trying to save the state of my NavigationPath for my NavigationStack in SwiftUI by pushing all the views to the stack at once. That way if the user taps the Back button, they will still see the ...
1
vote
1
answer
140
views
SwiftUI navigation link infinite loop causes app to freeze
I have the following SwiftUI set up
In my main, I have something like this
// singleton
@StateObject var authStatusManager = Factory.shared.authStatusManager
var body: some Scene {
WindowGroup {
...
1
vote
0
answers
188
views
How to use navigation paths when views are the same across tabs?
I have a tab view at the highest level, and right now, only one view has a navigation path cause I am working on adding the others, but I've run into a blocker first. I was planning for each tab view ...
1
vote
0
answers
198
views
Divider() not shown as it should be with SwiftUI
I want to make a divider in white with some opacity (under the navigation view) but for a reason I don't know the Divider() isn't shown as it should be.
Here's a screenshot of the design:
And here's ...
1
vote
0
answers
154
views
TabView Inside of NavigationStack has extra inset when ignoring Safe Area
I am using the following code to setup a TabView with a paging style inside of a NavigationStack
struct ContentView: View {
var body: some View {
NavigationStack() {
TabView {
...
1
vote
0
answers
240
views
How to fix Update NavigationAuthority bound path tried to update multiple times per frame
For navigation I am using the iOS 16 NavigationStack API. I keep my NavigationPath instance inside my view models as @Published instead of in the views with @State. When navigating between the ...
1
vote
0
answers
97
views
SwiftUI, prevent the subview to inherit parent's animation
I've been playing with the NavigationPath for some time. I first figured that when a view is inserted into the path (full code is on this answer), the inserted page doesn't have standard navigation ...
1
vote
1
answer
2k
views
SwiftUI - .navigationTitle and .toolbar not showing up
I'm following Apple's SwiftUI tutorial and currently stuck on this chapter. I'm trying to add a navigation title and toolbar to this View but it isn't showing up for some reason.
Here's my code:
...
1
vote
1
answer
156
views
Increase padding to NavigationStack title causes weird issue
I have a set up like this:
NavigationStack {
List {
ForEach(allProjects) { project in
Section {
NavigationLink(destination: ProjectView()) {
...
1
vote
0
answers
136
views
visionOS weird behaviour on NavigationStack title
I have a very simple navigation architecture so far, I left inner views (CourseDetail and CourseRows) as clean as possible to make sure there's nothing inside provoking the issue. Here's how it looks ...
1
vote
0
answers
625
views
Error with FullScreenCover in SwiftUI: A new orientation transaction token is being requested while a valid one already exists
I'm encountering an error when using the fullScreenCover modifier in SwiftUI. The error message states:
"A new orientation transaction token is being requested while a valid one already exists.&...
1
vote
0
answers
38
views
Deleting Object from EditView and Popping back to Root
Below is a simple representation of what I am trying to achieve in my own (much larger) application. This example has 3 Views:
ItemsView - displaying [Item]
DetailView - The selected Item with an ...
1
vote
0
answers
876
views
Path of NavigationStack inside NavigationSplitView emptied on change
I have the following view inside WindowGroup:
struct SidebarSelection: View {
@State var selection: Int?
@State var path: [Int] = []
var body: some View {
...
1
vote
1
answer
166
views
SwiftUI TextField mysteriously breaks navigation animation when used with NavigationPath
MRE
enum HomeDestination: Int, CaseIterable, Hashable, Identifiable {
case a
var id: Int { rawValue }
var name: String {
switch self {
case .a: return "A"
...
1
vote
0
answers
228
views
use navigationDestination(isPresented: ) and .navigationDestination(for: data) together
I come across a strange navigation bug, this is my code:
import SwiftUI
struct TestNavView: View {
@State var isPresented = false
var body: some View {
NavigationStack{
...
1
vote
0
answers
198
views
SwiftUI hanging with @Environment and NavigationStack when passing Bindings
I've got a NavigationStack and I'm passing bindings to multiple children through a couple of different views. If I don't pass the children as bindings then everything works as intended. Also if I ...
1
vote
0
answers
823
views
SwiftUI] access multiple NavigationStack
I use TabView & NavigationStack. TabView covered NavigationStack & inner View also covered NavigationStack. I want an inner navigation Push but it's always the root Navigation Push (in ...
1
vote
0
answers
204
views
Why is my navigation path not appending the model the further I go in?
I've implemented a navigation stack that appends the next view's view model so that the appending and .navigationDestination looks like the below. Whenever I press the continue button to add the ...
1
vote
1
answer
849
views
How to call Task in NavigationLink destination in SwiftUI?
I've created a list using LazyVStack and inside of the list there are ListItemViews.
What I'm trying to do is, when a ListItemView gets tapped, I want to make an async call depending on the selected ...
1
vote
1
answer
434
views
SwiftUI: Form pushes all navigation links on navigation stack
The idea is to use a Settings View in my App using a Form. However, it seems the Form itself pushes all NavigationLinks from the List view onto the navigation stack (at once). The typical (correct?) ...
1
vote
0
answers
147
views
How do I use NavigationStack on iOS 16 so that I don't have to explicitly create a Link with label that needs to be pressed?
I have a view that has a loading animation, basically when that call is done I want to automatically navigate to the following screen. Before with the isActive parameter I could create an empty view ...
1
vote
1
answer
91
views
Push user to a logged in view not working
For iOS16+, I am using Google Sign In button on ContentView to authenticate users. If users are not authenticated, the button shows and user can go through the authentication process. Once ...
1
vote
0
answers
222
views
SwiftUI passing TabView binding variable around in global EnvironmentObject
I've got a SwiftUI issue that only surfaces in a complex scenario.
My application has a TabView near the top of the view structure. There are 5 tabs in total. Tab 1 and 5 are pretty simple ScrollView ...
1
vote
1
answer
333
views
NavigationItem in nested NavigationStack is below NavigationBar
I'm making an app where you create acronyms and their meaning with SwiftUI
The flow of the app consists of having a List of Acronym, when tapping on any element it takes you to the detailView for that ...
1
vote
1
answer
2k
views
SwiftUI - NavigationLink and NavigationStack is not working with a button for iOS 16
I am making an app where I need to navigate to the home page when the user clicks on the Login button and when the Login button is clicked, the navigation link code is not working and shows a warning ...
1
vote
1
answer
219
views
Unwanted white space on Sheet
I have a basic tabview with 2 tabs. Tab 2 has a button to a modal sheet with a Page Style tabview imbedded in a Navigation Stack and added toolbar. When adding the Navigation Stack I get an unwanted ...
1
vote
0
answers
666
views
How to keep SwiftUI Navigation Swipe Back gesture, when NavigationStack has a padding?
I'm using SwiftUI's NavigationStack. When NavigationStack has a .padding(), the swipe back gesture no longer works. My best guess is that the gesture has to be triggered from the edge of the screen. ...
1
vote
0
answers
297
views
Is there a way to return the name of a Navigation Path in SwiftUI 4?
I'm trying to implement Pop to Root functionality in an app with a Tab View.
Here's my class where I define my Navigation Paths. Each path is assigned to a Tab. Tabs share child views that have a ...
1
vote
1
answer
1k
views
Found a strange behaviour of @State when combined to the new Navigation Stack - Is it a bug or am I doing it wrong?
I have transitioned my swiftui app to the new NavigationStack programmatically managed using NavigationStack(path: $visibilityStack). While doing so, I found an unexpected behaviour of @State that ...
1
vote
0
answers
186
views
SwiftUI appear transition doesn't work inside NavigationStack
When I tap on an item in a list, I'd like to transition a view in from the leading edge.
Currently:
When I use ListView by itself, the appear transition works fine.
When I wrap ListView in a ...
1
vote
1
answer
146
views
Shared toolbar items in SwiftUI NavigationStack
I have a navigation stack that's about three views deep. I want every single destination in this stack navigation to all have exactly the same toolbar items, a "Skip" button at the top right ...
0
votes
2
answers
73
views
NavigationLink as a Button in a list
I have NavigationStack with a List. I would like a NavigationLink to only trigger when Image(systemName: "info.circle") is tapped. Anywhere I place the NavigationLink, the whole row acts as ...
0
votes
2
answers
312
views
Undesired interplay between tapable, movable items and scrolling in SwiftUI List
I'm working on a SwiftUI list that shows tapable and long-pressable full-width items, which are movable, and allow for detail navigation.
I've noticed that .onLongPressGesture isn't detected when the ...
0
votes
1
answer
2k
views
NavigationStack iOS16 with Route, how to pop back to root?
I have the following navigation stack using route to go to differnet views:
import SwiftUI
import FirebaseAuth
import WebKit
enum Route:String, Hashable {
case linkSettings,
linkWallet
}
...
0
votes
1
answer
108
views
How to combine GroupBox or DisclosureGroup with a List in a SwiftUI NavigationStack
Ultimately, I am trying to replicate the layout used in Apple's Tips app:
The app appears to have a NavigationStack that contains non-list items but that fit the overall list style. When I try to ...
0
votes
2
answers
666
views
How to do programmatic navigation in swiftui using navigationstack once state changes?
struct LoginView: View {
@State var isUserLoggedIn = false
NavigationStack{
//.....
Button {
Task{
await viewModel.doLogin(email: ...
0
votes
1
answer
1k
views
SwiftUI NavigationStack Programmatic - Dismiss Multiple Views
Due to the horrible memory leaks when using NavigationPath() (initializing StateObjects numerous times, not releasing memory when views are removed from the stack, etc.), I am forced to use ....
0
votes
2
answers
566
views
NavigationLink doesn't work when View is embedded in a modal sheet
Weird problem.
I have a view called SecondView which has a NavigationLink like so:
struct SecondView: View {
var body: some View {
NavigationStack {
List {
...