Questions tagged [swiftui-tabview]

For questions about TabView - a component in Apple's SwiftUI framework that switches between multiple child views using interactive user interface elements. When using this tag also include the more generic [swiftui] tag where possible.

Links:

  • Apple Developer Documentation for TabView.
325 questions
2
votes
0 answers

SwiftUI TabView with PageTabViewStyle rotation issues

I am having some issues when rotating a paging TabView. I have the following code: struct ContentView: View { var body: some View { ZStack { Color(.systemGroupedBackground) .edgesIgnoringSafeArea(.all) …
alionthego
  • 8,508
  • 9
  • 52
  • 125
2
votes
0 answers

NavigationView inside TabView going to next page by default

I am wrapping my navigaton view inside a tab view. but when I load the app, my navigation view is always going to its next page by default. How can I stop this ? I spent so much time but could not figure it out. here is my view ZStack { …
2
votes
1 answer

View resizing when hiding tab bar with Introspect in SwiftUI

I'm using Introspect to hide the tab bar on child navigation link pages. However, I've noticed some odd behavior when the app is backgrounded and then brought back to the foreground. It seems like initially, the hidden tab bar is still taking up…
sia
  • 256
  • 3
  • 14
2
votes
0 answers

matchedGeometryEffect doesn't work with PageTabView

@Namespace var ns var body: some View { ZStack { Color(.black) TabView { ForEach(0..<5) { i in Text("item \(i)") .foregroundColor(.white) …
JackJack
  • 612
  • 2
  • 12
  • 28
2
votes
1 answer

How to dynamically tighten height for TabView?

The TabView seems to stretch to its maximum height, but I'd like it to shorten to height as much as it requires instead of empty space. This is what it looks like even tho there are Spacer views around it: struct ContentView: View { var body:…
TruMan1
  • 33,665
  • 59
  • 184
  • 335
2
votes
1 answer

SwiftUI - TabBar Button Change

I'm learning SwiftUI and I encountered a problem while trying to build an app. My question is how can I make a tab bar that changes a systemImage while active (when the home button is active it shows "home.fill", and when the user presses the search…
AnyOne
  • 21
  • 3
2
votes
1 answer

Showing alert from a tab in "More" overflow sends me back to the previous view

I have what should be a simple operation, show an alert in a SwiftUI app that uses a TabView. However, whenever I first show an alert from a tab that was pushed to the "More" overflow screen it immediately takes me back to whatever "main tab"…
Tyler V
  • 9,694
  • 3
  • 26
  • 52
2
votes
1 answer

Placing TabView inside NavigationView makes header transparent

TabView worked fine for me before i added NavigationView around it. Here's a normal behaviour A problem arises when i add NavigationView around my TabView - when scrolling I see "test" in front of black rectangle. I tried…
eugene_prg
  • 948
  • 2
  • 12
  • 25
2
votes
0 answers

TabView is all yellow in "preview"

I added TabView to my application and it was yellow for some reason in simulator & in preview mode. I found a workaround for simulator ( https://developer.apple.com/forums/thread/669833 ) and fixed this by changing the GPU preferences but can't…
eugene_prg
  • 948
  • 2
  • 12
  • 25
2
votes
1 answer

Dynamically set SwiftUI NavigationBarItems?

How can you dynamically change SwiftUI Navigation Bar Items? I have a TabView within a NavigationView, and I would like the Navigation Bar Items to change depending on tab that is selected. However, I am having a hard time determining how to change…
Brandogs
  • 145
  • 13
2
votes
1 answer

SwiftUI TabView seems to not respect @SceneStorage

I have an app that switches between TabView and Sidebar view depending on its sizeClass. The applicable code is below: struct PoshBoardTabView : View { @Environment(\.horizontalSizeClass) var sizeClass @SceneStorage("lastTab") var lastTab:…
Ferdinand Rios
  • 972
  • 6
  • 18
2
votes
1 answer

How to replace the current view in SwiftUI?

I am developing an app with SwiftUI. I have a NavigationView and I have buttons on the navigation bar. I want to replace the current view (which is a result of a TabView selection) with another one. Basically, when the user clicks "Edit" button, I…
1
vote
1 answer

How could I implement TabView page switching as a function of a selected date from DatePicker?

I've implemented the following code for my TabView and a DatePicker. I can currently slide between the three pages. And I can use the DatePicker to select between the 3 permitted days import SwiftUI struct DailyOverviewTab: View { @State private…
1
vote
1 answer

SwiftUI - Background color for view of tab item

Whenever I click on a tab on tabview, it opens a view. I wish to change the background color of that view. Doesn't matter what I do, it always stays white. Please look at the code and screenshot below: Note: In the screenshot below, ignore…
tech_human
  • 6,592
  • 16
  • 65
  • 107
1
vote
1 answer

SwiftUI - Disabling default selection of TabView

I am learning TabView and have a requirement where my main/content view will display map and will have TabView at the bottom. Whenever any of the tab's on TabView is tapped, a custom modal sheet (with slider handle to adjust sizes... more like…
tech_human
  • 6,592
  • 16
  • 65
  • 107