Questions tagged [ios-navigationview]

66 questions
4
votes
0 answers

How to get SwiftUI List and NavigationView with a background gradient?

When I scroll a List, I want to shrink the navigation bar from large to small. This works by default, but if I try to add a gradient behind the table, it doesn't work any more. Code is attached (try uncommenting the Gradient to see). How do I get…
user1007895
  • 3,925
  • 11
  • 41
  • 63
3
votes
1 answer

Dynamically change Navigation Title in SwiftUI?

Is it not possible to have a dynamic Navigation Title in SwiftUI. The below code doesn't update the title as the timer elapses. Is there any way to do this? (this is in WatchOS) (code edited for more testable example) import SwiftUI struct…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
3
votes
0 answers

Using view models in SwiftUI without allocation overhead

Using View Models in SwiftUI For a clean separation of concerns, I want to use my SwiftUI views with view models. I have two views, a ListView and a DetailView where the first pushes the latter when any list item is tapped – a classic navigation…
3
votes
3 answers

Navigate inside master instead of detail in SplitView in SwiftUI

I have a split view in my iPad ready app: struct ContentView: View { var body: some View { NavigationView { List { NavigationLink("Show the slave view HERE", destination: SlaveView()) …
Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
3
votes
0 answers

SwiftUI NavigationView on Apple Watch triggers multiple callings of onAppear in children views

Using Xcode Beta 12.3, the below code will call onAppear twice and print twice. When I comment out the NavigationView wrapping the ContentView, onAppear is only called once. Is this expected behavior? It seems that ANY NavigationView will trigger…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
3
votes
1 answer

SwiftUI transition from modal sheet to regular view with Navigation Link

I'm working with SwiftUI and I have a starting page. When a user presses a button on this page, a modal sheet pops up. In side the modal sheet, I have some code like this: NavigationLink(destination: NextView(), tag: 2, selection: $tag) { …
Evan
  • 1,892
  • 2
  • 19
  • 40
3
votes
3 answers

SwiftUI Nested NavigationView navigationBar disappears

I have a three views which are lists. struct MainMenuView: View { @EnvironmentObject var dataModel: DM var body: some View { return NavigationView{ List { Matchup() GameSettings() …
jimijon
  • 2,046
  • 1
  • 20
  • 39
3
votes
1 answer

Lifecycling in SwifUI: Running code when leaving a child view of a NavigationView hierarchy

With SwiftUI's NavigationView we benefit from simplicity with code construction. However, not exposed, at least in these early stages are the overrides. Further, the reduced focus on managing the LifeCycle of views makes it difficult to find out…
Justin Ngan
  • 1,050
  • 12
  • 20
2
votes
1 answer

Background color on Navigation Bar is not set when my SwiftUI based app is launched in landscape mode

I am working with a SwiftUI based app that relies on a NavigationView to transition from screens. I have a requirement to set the background color on the navigation bar and have found code that makes this work most of the time. When the app is…
CodeBender
  • 35,668
  • 12
  • 125
  • 132
2
votes
1 answer

How to add a trailing navigationbaritem conditionally to a SwiftUI View which will be presented in a NavigationView?

To add navigationBarItem to a SwiftUI View we can use code similar to this: NavigationView { Text("SwiftUI") .navigationBarTitle("Welcome") .navigationBarItems(trailing: Button("Help") { print("Help tapped!") …
Rohan Bhale
  • 1,323
  • 1
  • 11
  • 29
2
votes
3 answers

SwiftUI navigationView within Modal 'pushing' view down

I currently have a modal view in SwiftUI that contains a series of NavigationLinks to different views. However, when I go to one of the other views it pushes all the content down leaving a empty forehead at the top of the view. How do I fix this? I…
Thomas Braun
  • 1,109
  • 2
  • 13
  • 27
2
votes
1 answer

How do I add Animations to Transitons between custom NavigationItems made from AnyView?

Is there a way to add animations to transitions between custom NavigationItems made from AnyView as described in this article? I like everything about this NavigationStack system except for not being able to add any animated transitions. I…
Miss Swiss
  • 89
  • 1
  • 9
2
votes
0 answers

How to preserve pushed view when moving between tabs?

I have noticed that TabView has another behavior than UITabBarController, the view stack is cleared each time the user moves from one tab to another. I have created a small sample to illustrate my case: struct ContentView: View { @State private…
JKvr
  • 650
  • 7
  • 15
1
vote
0 answers

SwiftUI NavigationView drawer hidden in iPad Portrait

I have a SwiftUI master / detail NavigationView, with the master view being a list of countries, and the detail view being a list of cities in each country. This works fine in every layout (macOS catalyst, iPhone, iPad) except on an iPad in portrait…
Alnitak
  • 334,560
  • 70
  • 407
  • 495
1
vote
1 answer

Combine NavigationTitle and Navigation Back Button SwiftUI

I have an app that has a navigationLink from one view to another, but when the NavLink moves to the second view, the NavigationTitle of that view is pushed, down, it's not inline. Is there any way to combine the toolbar and the title? I put my code…
user18457910