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
8
votes
1 answer

SwiftUI onChange() event doesn't work on TabView when swiping

I would like to change the value of a text when the active tab of a TabView changes. I tried using onChange(of: activeTab, perform: {}) to change the value of the state variable that stores the text but it seems that the closure given to onChange()…
derivmug
  • 163
  • 1
  • 7
8
votes
1 answer

TabView with PageTabViewStyle() not using available height in ScrollView

so I have a TabView like shown below, but when I try to implement it in a ScrollView I always have to give it a fixed height. Is there a way of telling the tabview to use the space it needs in the scrollView? I don't know the height of the inner…
Paul
  • 153
  • 7
7
votes
2 answers

How to update SwiftUI's ForEach in a TabView with PageTabViewStyle modifier when inserting a new element to the collection at first index

This is a very specific issue when using ForEach in a TabView with PageTabViewStyle modifier. Every time I'm inserting an element at the beginning of my array my app crashes. I'm getting a attempt to delete item 11 from section 0 which only…
Marco Boerner
  • 1,243
  • 1
  • 11
  • 34
6
votes
1 answer

SwiftUI TabView memory footprint continuously increases when changing page

struct ContentView: View { @State private var selectedIdx = 0 var body: some View { TabView(selection: $selectedIdx) { ForEach(0..<5) { idx in Text("\(idx)") } } …
dushandz
  • 117
  • 5
5
votes
2 answers

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)? By default my code look like this: struct…
5
votes
2 answers

How can I remove an item from a ForEach inside of a TabView using SwiftUI?

I am having a weird SwiftUI crash that I am not understanding. I have a TabView with a list of 3 images inside of it. I am trying to remove the first image from the list by tapping on the button on the screen, but I get this…
Cameron Henige
  • 368
  • 2
  • 17
5
votes
1 answer

Nested TabView - Remove inner tab bar iOS 13, Swift UI

I am using a TabView to represent three tabs. In iOS 14, this is handled nicely, but iOS 13 results in a gray bottom bar which is the tab bar for navigation. How can I remove this bar? Please bear in mind that this is a TabView within a TabView. The…
McGuile
  • 818
  • 1
  • 11
  • 29
4
votes
1 answer

I created a custom tab bar in SwiftUI, but when I select a tab, it completely reloads the view. How do I prevent this

I created a custom tab bar I am using a switch statement to switch between my views The problem is that the view is being reloaded everytime I switch between tabs How do I "save" the state of the view when I switch between views? So for example,…
4
votes
1 answer

auto repeat pageview in swiftui

I have a swiftui project. I am using pageview. Normally, when it comes to the last page, it does not scroll further because the pages are finished. What I want is this: the pages continue after reaching the last page. Let's start again from the…
ursan526
  • 485
  • 3
  • 10
4
votes
1 answer

Disable Tab View Swipe to Change Page in SwiftUI 2.0

I am using a tab view in my SwiftUI app. I want to disable its swipe to left and write to move to other pages. I checked this answer and also checked this one, but none of them works. They are using .gesture(DragGesture()) which is disabling the…
Taimoor Arif
  • 750
  • 3
  • 19
4
votes
1 answer

How can I adjust the size of an image in a SwiftUI tabItem?

I want to use custom images/icons in my TabView, but when I use a custom image instead of a system image, the image is too large. I've tried to adjust via .frame but it seems to have no effect. I've also tried to resize the photo itself before using…
Nate Thompson
  • 325
  • 2
  • 12
4
votes
2 answers

How to Add Space Above TabBar Icons in SwiftUI

I'm working with SwiftUI and made a tab bar that looks like this: The spacing above the icons is pretty minimal, and I'd like to either add some padding to the top of it or increase the height of the bar itself and vertically center the icons. My…
Nicolas Gimelli
  • 695
  • 7
  • 19
4
votes
2 answers

SwiftUI TabView Content Being Clipped

I am using a TabView with a page style to display scrollable cards that snap into place. I've placed the TabView in a HStack with spacers on each end which centers the TabView. The TabView also has a width of 80% of the HStack. I'd love to have the…
4
votes
1 answer

SwiftUI: resetting TabView

I have a TabView with two tabs in a SwiftUI lifecycle app, one of them has complex view structure: NavigationView with a lot of sub-views inside, i.e.: NavigationLinks and their DestinationViews are spread on multiple levels down the view tree, each…
JAHelia
  • 6,934
  • 17
  • 74
  • 134
4
votes
0 answers

SwiftUI: showing keyboard in a tab view adds a weird space below second tab view

This sounds a bug in SwiftUI's NavigationView and TabView, when I have a TabView with (let's say) 2 tabs, the first tab has a TextField and the second tab has a NavigationView, follow these steps to produce the bug: show the keyboard by tapping on…
JAHelia
  • 6,934
  • 17
  • 74
  • 134
1
2
3
21 22