Questions tagged [navigationlink]

73 questions
105
votes
5 answers

NavigationLink Works Only for Once

I was working on an application with login and after login there are categories listed. And under each category there are some items listed horizontally. The thing is after login, main page appears and everything is listed great. When you click on…
C.Aglar
  • 1,290
  • 2
  • 14
  • 30
32
votes
10 answers

SwifUI onAppear gets called twice

Q1: Why are onAppears called twice? Q2: Alternatively, where can I make my network call? I have placed onAppears at a few different place in my code and they are all called twice. Ultimately, I'm trying to make a network call before displaying the…
AvsBest
  • 435
  • 1
  • 4
  • 9
14
votes
9 answers

Runtime error: precondition failure: attribute failed to set an initial value

I have a view BugSplitView which works fine alone but causes a precondition failure: attribute failed to set an initial value error when navigated to in either preview or the simulator. The view has an upper part (Color) and a lower part (Color)…
Rumbles
  • 806
  • 1
  • 8
  • 15
13
votes
1 answer

Use NavigationLink programmatically in SwiftUI

I'm looking for a way to display a view in my WatchOS application "one level in" from the NavigationView on app startup if certain conditions are met. I want the same effect as if I would have pressed a NavigationLink myself, i.e being able to go…
heinz_dieter
  • 315
  • 1
  • 4
  • 12
12
votes
2 answers

Is there a way to add an extra function to NavigationLink? SwiftUI

I would like to add an extra function to the NavigationLink. example code is something like this: struct ContentView: View { func yes () { print("yes") } var body: some View { NavigationView { NavigationLink(destination: level1()) { …
I Kaya
  • 417
  • 5
  • 22
11
votes
1 answer

Supporting SwiftUI navigation in legacy projects

I'm wondering if there's any way to start using SwiftUI in a legacy project and still be able to navigate back and forth SwiftUI scenes. That is, let's imagine I just want to support the last iOS 13 for a project I've been working on for the last…
Fernando
  • 751
  • 2
  • 13
  • 27
9
votes
2 answers

How can I initialize View Again in SwiftUI?

I’m using SwfitUI in my project and I have a NavigationView and List. I’m clicking cell after open the detail view and click navigation back button. I want to remove view (it’s struct, in SwiftUI) after click navigation back button. Because if I…
Erkam KUCET
  • 485
  • 8
  • 21
8
votes
2 answers

How to put a condition to NavigationLink? SWIFTUI

I would like to put a condition to the NavigationLink. I have two variable, and the NavigationLink as below. @State var score = 0 @State var target = 10 NavigationLink(destination: level2()) { Text("Next Level") } Is there a way to…
I Kaya
  • 417
  • 5
  • 22
8
votes
3 answers

SwiftUI NavigationLink pops automatically which is unexpected

I am having some issues with a NavigationLink on an iPad with split view (landscape). Here is an example: Here is the code to reproduce the issue: import SwiftUI final class MyEnvironmentObject: ObservableObject { @Published var isOn: Bool =…
Thomas Vos
  • 12,271
  • 5
  • 33
  • 71
7
votes
1 answer

How to remove opacity animation in SwiftUI NavigationLink

When tapping on a NavigationLink, it reduces the opacity slightly. Is there a way to disable this. I tried using .buttonStyle(PlainButtonStyle()) but that didn't have the desired effect. It is embedded in a scrollView (preferred over List for…
santi.gs
  • 514
  • 3
  • 15
7
votes
2 answers

SwiftUI Navigation automatically closing/pop - Realm

I'm populating a List with a Realm Result set. When navigating from this list it opens a new view then automatically closes that view. Using a struct presents no issue. Why would the second view automatically close? I have a screen recording but…
Yarm
  • 1,178
  • 4
  • 16
  • 29
7
votes
1 answer

How to make SwiftUI NavigationLink work in edit mode?

I have a list of items. Clicking on one should push a new view to the navigation stack. I notice the NavigationLink doesn't work if the list is in edit mode. Is there a way to control that? I need it to work in edit mode. List { …
Rob N
  • 15,024
  • 17
  • 92
  • 165
7
votes
1 answer

Pass information to another view with NavigationLink

I have following View and I need to pass item content to another View (DetailsEvent.swift), I am using NavigationLink . (I'm using Xcode 11 GM) struct Events: View { @ObservedObject var networkManager = NetworkManager() var body: some View…
Mario Burga
  • 1,107
  • 1
  • 13
  • 19
7
votes
2 answers

SwiftUI NavigationLink Button is gray and untouchable

I can not get a NavigationLink in SwiftUI. The button is visible, but unfortunately this is gray and can not be clicked. Here is the code: import SwiftUI import Combine struct ContentView: View { var body: some View { NavigationView{ …
CodierGott
  • 471
  • 1
  • 5
  • 10
6
votes
1 answer

SwiftUI - Using Navigation View and Sheets correctly

Having issues with a NavigationView and Sheet. I have the below flow: - ContentView: Has button that opens ContentView2 sheet - ContentView2: Has NavigationLink with header that goes to ContentView3 - ContentView3: Has NavigationLink, no header,…
glothais-kwl
  • 151
  • 1
  • 7
1
2 3 4 5