Questions tagged [swiftui-navigationlink]

For questions about NavigationLink - a component in Apple's SwiftUI framework that triggers a navigation presentation when pressed. When using this tag also include the more generic [swiftui] tag where possible.

Links:

974 questions
138
votes
14 answers

SwiftUI - how to avoid navigation hardcoded into the view?

I try to do the architecture for a bigger, production ready SwiftUI App. I am running all the time into the same problem which points to a major design flaw in SwiftUI. Still nobody could give me a full working, production ready answer. How to do…
Darko
  • 9,655
  • 9
  • 36
  • 48
34
votes
4 answers

How to disable NavigationView push and pop animations

Given this simple NavigationView: struct ContentView : View { var body: some View { NavigationView { VStack { NavigationLink("Push Me", destination: Text("PUSHED VIEW")) } } } } Did…
kontiki
  • 37,663
  • 13
  • 111
  • 125
27
votes
1 answer

SwiftUI NavigationView trying to pop to missing destination (Monoceros?)

I'm using Xcode 12 with deployment for iOS 14.0. My home screen has a NavigationView Within the NavigationView there is a TabView (with 4 tabs) Within each tab are subviews that have buttons and NavigationLinks The navigation on the app is…
nicksarno
  • 3,850
  • 1
  • 13
  • 33
25
votes
5 answers

SwiftUI NavigationLink pops out by itself

I have a simple use case where a screen pushes another screen using the NavigationLink. There is a strange behaviour iOS 14.5 beta (1, 2, 3), where the pushed screen is popped just after being pushed. I manage to create a sample app where I…
Jan
  • 7,444
  • 9
  • 50
  • 74
23
votes
2 answers

SwiftUI Error: "Closure containing control flow statement cannot be used with function builder 'ViewBuilder'"

I tried a SwiftUI tutorial, "Handling User Input". https://developer.apple.com/tutorials/swiftui/handling-user-input I tried implementing it with for instead of ForEach. But an error arose: "Closure containing control flow statement cannot be used…
23
votes
9 answers

SwiftUI List disclosure indicator without NavigationLink

I am searching for a solution to show the disclosure indicator chevron without having the need to wrap my view into an NavigationLink. For example I want to show the indicator but not navigate to a new view but instead show a modal for example. I…
grahan
  • 2,148
  • 5
  • 29
  • 43
22
votes
2 answers

SwiftUI List is not showing any items

I want to use NavigationView together with the ScrollView, but I am not seeing List items. struct ContentView: View { var body: some View { NavigationView { ScrollView{ VStack { Text("Some…
Winten
  • 574
  • 2
  • 8
  • 15
17
votes
1 answer

'init(destination:isActive:label:)' was deprecated in iOS 16.0: use NavigationLink(value:label:) inside a NavigationStack or NavigationSplitView

I have tried different iterations of examples posted on this site but nothing is going right. I have also tried following the examples listed here: Navigation to new navigation types: I am getting the warning in this posts' title for deprecation of…
LizG
  • 2,246
  • 1
  • 23
  • 38
17
votes
3 answers

SwiftUI NavigationLink Bug (SwiftUI encountered an issue when pushing aNavigationLink. Please file a bug.)

Console Bug: SwiftUI encountered an issue when pushing aNavigationLink. Please file a bug. There is no problem when I don't use the isActive parameter in NavigationLink. However, I have to use the isActive parameter. Because I'm closing the…
Ufuk Köşker
  • 1,288
  • 8
  • 29
17
votes
1 answer

SwiftUI .toolbar disappears after following NavigationLink and coming back

I've added a .toolbar to the top level of a NavigationView that will eventually be used to select items in a list without using swipe gestures (up button, down button, etc.). I also have a .navigationBar going on, to access other views for Account…
17
votes
2 answers

SwiftUI Navigation Multiple back button

When I push more than one view, multiple back buttons are visible in the navigation bar. struct ContentView: View { var body: some View { NavigationView { NavigationLink(destination:SecView()) { …
Stefano Toppi
  • 626
  • 10
  • 28
15
votes
4 answers

How do you fix Xcode 14 warning: NavigationLink presenting a value must appear inside a NavigationContent-based NavigationView. Link will be disabled

Since installing Xcode 14, I am now getting the following error message printed in my console: NavigationLink presenting a value must appear inside a NavigationContent-based NavigationView. Link will be disabled. My app is structured as…
14
votes
5 answers

NavigationLink isActive deprecated

In the new version of iOS and Xcode NavigationLink(isActive: , destination: , label: ) is deprecated. How do we control the status of NavigationLink then?
Steven-Carrot
  • 2,368
  • 2
  • 12
  • 37
14
votes
1 answer

SwiftUI: Adding .onDrag blocks clicking/selecting an item in the macOS sidebar

I have a list in my macOS app’s sidebar. When I add the .onDrag modifier, dragging NSItemProvider works correctly, but clicking/selecting the item to trigger the NavigationLink gets blocked. struct ContentView: View { var body: some View { …
Frank R
  • 841
  • 5
  • 13
14
votes
1 answer

Create a SwiftUI Sidebar

I want to build a very simple iOS 14 sidebar using SwiftUI. The setup is quite simple, I have three views HomeView, LibraryView and SettingsView and an enum representing each screen. enum Screen: Hashable { case home, library, settings } My…
jlsiewert
  • 3,494
  • 18
  • 41
1
2 3
64 65