Questions tagged [swiftui-navigationview]

For questions about NavigationView - a view in Apple's SwiftUI framework that presents a stack of views representing a visible path in a navigation hierarchy. When using this tag also include the more generic [swiftui] tag where possible.

Links:

583 questions
0
votes
0 answers

onAppear modifier called twice when applying .navigationViewStyle(.stack) on NavigationView

[Summarize the problem] .onAppear modifier called twice when using .navigationViewStyle(.stack) on NavigationView. [Describe expected and actual results] I am expecting .onAppear to be called once but .onAppear is called twice. EDIT: I Removed the…
0
votes
0 answers

Display the same view across multiple tabs, swiftui

I have an app with a TabView. One of these tabs(1) displays a CartView. There is another tab(2) that Adds items to the cart and Also allows Navigation to the CartView. The contents of the cart are maintained in an EnvironmentObject CartModel…
Pradyot
  • 2,897
  • 7
  • 41
  • 58
0
votes
1 answer

SwiftUI Nested NavigationLink causing double transition

Running on iOS 15. When I select a NavigationLink from ItemListView, the resultant ItemView animates onto the screen twice. I’ve discovered two (anti)fixes to this problem: Don’t use nested NavigationLinks. If I treat ItemListView as the…
0
votes
0 answers

Why does deleting a NavigationLink after recently visiting on it crash the app?

The following is a project I created to demonstrate my problem. Whenever I click and view a navigation link from the Content View and then delete it from Content View, the app crashes with the error, "Thread 1: Fatal error: Unexpectedly found nil…
0
votes
1 answer

Slide Over in iPadOS 15 breaks NavigationLink (SwiftUI)

I’m having issues when using NavigationView and NavigationLinks on iPadOS 15. Currently running Dev Beta of iPadOS 15.3 (19D5026g), but I’ve had this issue since the release of 15.1. When I’m using my app as usual, nothing is wrong. But when I turn…
0
votes
1 answer

SwiftUI pass data from view to view

I spent 14 hours trying to figure it out today, I went over here, googled, and watched videos but nothing helped. I gave up so I decided to ask a question. Typically, I have two views in one, such as the list on the left and details on the right. On…
0
votes
1 answer

SwiftUI NavigationLink issue with multi selections

I have an issue with SwiftUI navigation. To show the issue I made a simple example of a list of cars and if the user clicks on it, it shows the car details: struct ContentView: View { var cars = [Car(name: "A"), Car(name: "B"), Car(name: "C"),…
pierre23
  • 3,846
  • 1
  • 28
  • 28
0
votes
1 answer

SwiftUI adding a UISearchBar to the navigation bar

So I'm relatively new to SwiftUI, and I'm trying to add a UISearchBar into my navigation bar, but I'm having trouble getting it to show up. If I add it as a separate component, it appears but it's too far down the screen. Here's what I have so…
0
votes
1 answer

Auto pop navigation link issue

I have a problem with auto view poping pushed view via Navigation Link. On my ContentView is a list which can be changed after a few seconds, but if I push a new view before it, new view pops automatically after new data appears. It is unexpected…
PiterPan
  • 1,760
  • 2
  • 22
  • 43
0
votes
1 answer

@Published property has a delay when used as navigationBar's title

I just noticed that when using a @Published property as navigation's title, there is some delay while displaying the value (but if the subscription is made on the ViewModel's init, it display instantly), but also the delay is only on the…
0
votes
1 answer

swiftUI NavigationView centered logo righ and right button

I am trying to make a NavigationView in SwiftUI that has a logo centered and a button right justified. Here is what I have tried with no success. I cannot figure out how to remove the title and replace it with a image logo. .navigationBarTitle("",…
LilMoke
  • 3,176
  • 7
  • 48
  • 88
0
votes
0 answers

How to setup NavigationLink in SwiftUI sheet to redirect to new view

I am attempting to build a multifaceted openweathermap app. My app is designed to prompt the user to input a city name on a WelcomeView, in order to get weather data for that city. After clicking search, the user is redirected to a sheet with…
0
votes
0 answers

How to update previous view upon dismissing the sheet view in swiftui

I was able to make it work when I have two views where firstView knows that if second view was dismissed or not. First View presents Second View Upon dismissing second view, first view knows it was dismissed here is the code struct FirstView: View…
user4150758
  • 384
  • 4
  • 17
0
votes
0 answers

How can I prevent SwiftUI view from disappearing onViewWillDisappear?

I have a case where one of my SwiftUI Views is automatically going back to previous screen on a published variable change, which is not related to isActive. I want to stop navigating the swiftUI view onViewWillDisappear(). How can I stop SwiftUI…
0
votes
1 answer

Split view on iPad portrait mode results in a useless view being presented on startup

With the following code, Useless View is shown on app startup for iPads in portrait mode. One press of the Back button results in the detail view showing "Link 1 destination". Only upon the second press is the sidebar shown. This is not the behavior…
Steve M
  • 9,296
  • 11
  • 49
  • 98