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.
610
questions
219
votes
26
answers
146k
views
How to remove the default Navigation Bar space in SwiftUI NavigationView
I am new to SwiftUI (like most people) and trying to figure out how to remove some whitespace above a List that I embedded in a NavigationView.
In this image, you can see that there is some white ...
38
votes
4
answers
15k
views
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("...
36
votes
3
answers
42k
views
SwiftUI – How to set the title of a NavigationView to large title (or small)?
Using SwiftUI how do I change the navigation bar's title size? Choosing between a standard or a large title.
29
votes
1
answer
6k
views
SwiftUI iOS14 - NavigationView + List - Won't fill space
I'm having an issues with a List inside a NavigationView since iOS 14 update.
Here is a simple breakdown of the code - I've striped everything that doesn't show the issue
struct ContentView: View {
...
29
votes
5
answers
11k
views
macOS SwiftUI Navigation for a Single View
I'm attempting to create a settings view for my macOS SwiftUI status bar app. My implementation so far has been using a NavigationView, and NavigationLink, but this solution produces a half view as ...
20
votes
5
answers
11k
views
Make List Sections non-collapsible in SwiftUI when embedded into a NavigationView SwiftUI
When I embed a List grouped into Sections into a NavigationView the section headers become collapsible. I'd like to keep them non-collapsible, just like when the List is not embedded into the ...
18
votes
7
answers
17k
views
SwiftUI Hide TabView bar inside NavigationLink views
I have a TabView and separate NavigationView stacks for every Tab item. It works well but when I open any NavigationLink the TabView bar is still displayed. I'd like it to disappear whenever I click ...
18
votes
2
answers
4k
views
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 ....
17
votes
4
answers
10k
views
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 ...
15
votes
3
answers
3k
views
Where to place global NavigationPath in SwiftUI
I'm currently developing an app using NavigationStack. I wonder where should I put the NavigationPath variable so I can modify it anywhere.
I tried to put it inside the root view as a State variable, ...
12
votes
5
answers
17k
views
SwiftUI: how to change NavigationView.toolbar background color
Any idea on how to apply a specific background color to the bottom toolbar?
NavigationView {
List {
....
}
.toolbar {
ToolbarItem(placement: .bottomBar) {
...
12
votes
3
answers
3k
views
SwiftUI Navigation popping back when modifying list binding property in a pushed view
When I update a binding property from an array in a pushed view 2+ layers down, the navigation pops back instantly after a change to the property.
Xcode 13.3 beta, iOS 15.
I created a simple demo and ...
12
votes
1
answer
1k
views
SwiftUI - NavigationView title and back button clipped under status bar after orientation change
Whenever I rotate the device to landscape and back again, the top of the NavigationView (including the title and back button) get clipped under the status bar.
Minimal reproducible example:
struct ...
12
votes
2
answers
693
views
Keep navigation bar title during search with Searchable
Is it possible to not hide the Title in Navigation Bar in search mode using Searchable? Using the code below Title in Navigation Bar is hidden when Search Field is focused.
NavigationView {
}
...
11
votes
1
answer
4k
views
searchable modifier not displaying search bar below navigation bar title
I'm using iOS 15 and trying out the new searchable modifier on Lists in SwiftUI. It looks like when you attach searchable(text: $searchText) to a NavigationView the search bar renders on the screen by ...
11
votes
1
answer
2k
views
What is the difference between navigationBarTitle and navigationTitle modifiers in SwiftUI 2.0?
Learning all the new SwiftUI 2.0 changes but came across .navigationTitle which seems to work almost exactly like .navigationBarTitle. I looked at the WWDC 2020 videos and found one video where it was ...
10
votes
2
answers
5k
views
SwiftUI Error: Update NavigationAuthority bound path tried to update multiple times per frame
I am getting the following debug message:
"Update NavigationAuthority bound path tried to update multiple times
per frame."
Does anyone know how to resolve the output message?
I can't find ...
10
votes
1
answer
7k
views
SwiftUI navigation titles within TabView
For the reason outlined in the answer outlined in this question SwiftUI TabView brightness views vertical location the menu structure for my app is NavigationView -> TabView -> sub view with ...
10
votes
1
answer
2k
views
Navigation + Tabview + Sheet broken in iOS 15
It looks like Navigation + TabView + Sheet is broken in iOS 15.
When I do this:
ContentView -> DetailView -> Bottom Sheet
When the bottom sheet comes up, the Detail view is automatically popped ...
9
votes
2
answers
5k
views
Add accessory view below navigation bar title in SwiftUI
I’m trying to add an accessory view embedded in a navigation bar below the title, which can be seen in the default iOS calendar app (the “s m t w t f s” row) or the GitHub mobile app:
And I’d like it ...
9
votes
2
answers
6k
views
Remove screen from navigation stack in SwiftUI
I'm using NavigationLink to navigate screens in NavigationView.
How can I remove screen from navigation stack?
Not just hide the navigation "Back" button but completely remove screen from ...
9
votes
0
answers
1k
views
Why does the navigation title display mode change from large to inline when popped in iOS 16?
When I pop from a pushed view that has a display mode of inline the display mode of the parent view which was originally large is changed to inline and the user has to scroll down for the title to ...
8
votes
1
answer
5k
views
Scroll View Items Come Over the Navigation Bar in SwiftUI
I made a custom nav bar. and added a scroll view below it. The problem I am getting is when I scroll down, the data inside scroll view comes over the navigation bar. Here is the screenshot:
My code ...
8
votes
3
answers
8k
views
SwiftUI's NavigationLink `tag` and `selection` in NavigationView stops working if not all NavigationLinks are displayed
I have a list of items in a Form in a NavigationView, each having a detail-view that can be reached with NavigationLink.
When I add a new element to the list, I want to show its detail-view. For that ...
8
votes
2
answers
4k
views
SwiftUI NavigationView remove white space
I have a HomeView
NavigationView {
ZStack {
VStack {
NavigationLink(destination: ProfileView()) {
if session.userInSession?.activated != 1 {
...
8
votes
1
answer
1k
views
SwiftUI Toolbar item getting clipped when back button is pressed
I've run in to a strange behavior in SwiftUI that I can't seem to work around.
Given the following simple example app I experience this behavior: The toolbar item renders correctly on the initial run, ...
8
votes
1
answer
2k
views
How to push onto an existing UINavigationController stack from SwiftUI?
We're pushing to a SwiftUI view embedded in a UIHostingViewController in UIKit land like this:
First making the UIViewController:
func hostingController() -> UIViewController {
let ...
8
votes
2
answers
3k
views
Too much space left between items when using ToolbarItemGroup
When I use toolbar group in SwiftUI, there is too much space between elements. I put it with HStack in iOS 13, it is ok. But when I put it with toolbar in iOS 14, there is a problem. How can I fix ...
8
votes
0
answers
667
views
SwiftUI preview's subviews are unselectable when embedded in NavigationView
When I embed my view's body inside of a NavigationView I lose all ability to select subviews within the preview window, as well as the reverse ability of selecting code to trigger and display the blue ...
7
votes
1
answer
12k
views
swiftui list with custom header
I want to set a image header for list in swiftui. The effect I want is shown in the figure below:
However, I can not remove padding in this image row. My code is as bellow:
import SwiftUI
struct ...
7
votes
1
answer
2k
views
SwiftUI macOS toolbar icons alignment for three column layout
Following this question, how to add a toolbar divider for a three column view in swiftUI life cycle
, I have a slightly different issue. I am trying to achive the same thing but the second and third ...
7
votes
1
answer
6k
views
SwiftUI: How can I determine if a view is presented in a NavigationView, Sheet, or is the root?
I'm working on a project that requires a custom navigation bar that will have custom buttons and title styling, while also allowing an accessory view below the main nav portion.
Essentially, I'd like ...
6
votes
2
answers
2k
views
SwiftUI NavigationView content only visible in iPad sidebar
My app is working as expected across all iPhone models, but when running on iPad I notice that the my application content, which is wrapped within a NavigationView, only displays in the iPad's sidebar,...
6
votes
3
answers
2k
views
SwiftUI - Navigation bar back button appears for a fraction of second
I have looked into many solutions but none of them works. My app navigation flow is
ViewController (UIKit) - pushes to SwiftUI view
This SwiftUI view shows the back bar button for a fraction of ...
6
votes
2
answers
2k
views
Blur effect on SwiftUI NavigationBar stops working if I add content to the bottom of my view
I have a very simple View with NavigationBar and a List in a VStack. If I scroll up on the list, the list contents will appear behind the NavigationBar with a nice blur effect by default. This ...
6
votes
1
answer
2k
views
In SwiftUI, how can I avoid redrawing a parent view while updating shared state data from a child view to avoid Navigation issues?
Since Xcode 12.5, I am seeing a lot of "Unable to present. Please file a bug." console logs in the Xcode console which I remember not seeing prior to 12.5.
This message is shown when I am ...
6
votes
0
answers
462
views
SwiftUI toolbar covered by keyboard accessory view
Hi there I have a tricky problem to solve with SwiftUI in Xcode 12.4 (iOS 14): given I have a Form with numerous sections and TextEditors, this form having a .toolbar modifier (bottom bar) with some ...
6
votes
0
answers
2k
views
Navigation bar title stays inline in iOS 15
I have a NavigationView that contains a ScrollView with a large title. When I navigate to a page with an inline title, then navigate back, the title stays inline rather than reverting to the large ...
6
votes
3
answers
3k
views
NavigationView bar material invisible on iOS 15
On iOS 15, an app with a NavigationView with .inline mode no longer shows the blurry material color you would see for the navigation bar.
Example code:
struct ContentView: View {
var body: some ...
6
votes
0
answers
467
views
Programmatic navigation with NavigationView/NavigationLink delay jumps back
I created a simple showcase where my problem can be reproduced; what I'm doing is navigating from the initial view => View1 => View2.
The navigation from the initial to View1 happens via button ...
6
votes
0
answers
641
views
SwiftUI NavigationView issue with Parent-Child-Grandchild scenario when attempting grandchild previous next navigation
I am using SwiftUI in a project that requires a model with a 'one to many to many' entity structure. I use a navigation view at the parent level with navigation links at parent and child levels.
This ...
5
votes
2
answers
2k
views
Swiftui: align selected text in picker to leading edge
Currently I've a picker included in a Section included in a Form what I'm trying to reach is to align the selected value of the picker to the leading in both iOS 13 and 14, I've tried many solutions ...
5
votes
4
answers
1k
views
Why is viewModel not deiniting with a NavigationView?
I've got a problem with an object not being destroyed when put into the environment and used with a NavigationView. If a view creates an object, creates a NavigationView and inserts the object into ...
5
votes
2
answers
5k
views
Create a common layout for the navigation bar in SwiftUI, so other SwiftUI views should reuse same Nav Bar
In iOS SwiftUI, how can we make a common layout for the navigation bar, so we can use that in all projects without rewriting the same code?
We can use ViewBuilder to create a base view for common ...
5
votes
2
answers
2k
views
How to show in SwiftUI the sidebar in iPad and portrait mode
I have an master detail app in iPad, and when run the app in portrait mode the sidebar is hidden. I need to push Back button to open the sidebar.
Can anyone help me to show the sidebar by default?
I ...
5
votes
1
answer
2k
views
TabView is not switching tabs properly in SwiftUI
I'm having a weird problem that I can't seem to figure out with SwiftUI. I have a TabView in my ContentView, there are 3 tabs (chat list, user list, and profile) the app loads up on the chat list tab. ...
5
votes
3
answers
1k
views
SwiftUI: Detect NavigationView goes back to main view
I have a NavigationView and the following view structure ViewA -> ViewB -> ViewC and I'm trying to figure out how to detect when ViewB goes back to ViewAViewB -> ViewA. Here is my Code:
...
5
votes
2
answers
2k
views
SwiftUI hidesBottomBarWhenPushed equivalent?
I'm trying to hide my TabView when I push a new view in my NavigationView but for now it seems that there is no way to do it (I saw a lot of thing on Internet, but nothing seems work properly for me)?
...
5
votes
1
answer
2k
views
NavigationLink keeps aligning my text elements to center instead of leading SwiftUI
I have a CustomSearchBar view that looks like this
However, when I wrap it with NavigationLink, the placeholder text will be centered. And user inputs will be centered too.
How do I maintain the ...
5
votes
0
answers
277
views
How to know when SwiftUI presentation has finished?
I want to know when my SwiftUI view has finished it's transition/animation in order to safely present additional views/modals.
Example:
I am in View A showing Sheet A.
Within Sheet A I tap a button ...