Questions tagged [tabview]

Any visual layout that incorporates selectable tabs as an organizational element.

770 questions
50
votes
3 answers

Preserving state between tab view pages

issue I have two ListViews rendering inside of a TabBarView using a TabController. How do I preserve state (for lack of a better word) between each ListView so that: 1.) the Widgets don't rebuild and 2.) the ListView position is remembered between…
Colin Ricardo
  • 16,488
  • 11
  • 47
  • 80
30
votes
3 answers

OnAppear calls unexpectedly when Keyboard Appears in SwiftUI

I am experiencing very odd behavior in SwiftUI 2.0 and iOS14. When the keyboard appears on the screen, the OnAppear method of other tab's view called automatically. However, this works fine Xcode 11.7 Here is the issue in action. Here is the code…
Malav Soni
  • 2,739
  • 1
  • 23
  • 52
28
votes
3 answers

How to set a default Tab in SwiftUIs TabView?

I have a TabView in SwiftUI and want the second tab to be the default, when starting the app. I haven't found any documentation to provide this behavior, but it should be possible. Most of the apps have the mid tab as their default tab. TabView { …
Seb
  • 1,586
  • 1
  • 11
  • 15
26
votes
3 answers

How to disable vertical scroll in TabView with SwiftUI?

I have set up a TabView in my application, so that I can swipe horizontally between multiple pages, but I also have an unwanted vertical scroll that may appear, with a bounce effect so. How can I disable this vertical scroll? My code: struct…
Guillaume
  • 1,500
  • 3
  • 24
  • 33
19
votes
6 answers

SwiftUI 2.0 TabView disable swipe to change page

I have a TabView thats using the swiftUI 2.0 PageTabViewStyle. Is there any way to disable the swipe to change pages? I have a search bar in my first tab view, but if a user is typing, I don't want to give the ability to change they are on, I…
daee kang
  • 285
  • 1
  • 3
  • 9
18
votes
3 answers

How to build a TabView using Flutter GetX

I'm trying to build a app using Flutter with GetX for State Management, and in one of my pages i need to build a TabView widget in the middle of the page, i already found a lot of stuff explaining how to build a TabView as widget, as this post and…
Patrick Freitas
  • 681
  • 1
  • 5
  • 18
15
votes
3 answers

How to maintain scroll position in a SwiftUI TabView

Using a ScrollView inside a TabView I've noticed that the ScrollView does not maintain it's scroll position when I move back an forth between tabs. How do I change the below example to get the ScrollView to maintain it's scroll position? import…
oivvio
  • 3,026
  • 1
  • 34
  • 41
15
votes
4 answers

Changing Tab Bar Color (Swift)

I am trying to change the tab bar color in a view controller in XCode using swift. I have a hex that I matched up to an RGB value and I am trying to set that in this code. (Which does not work) let color = UIColor(red: 41, green: 40, blue: 39,…
Jordan
  • 211
  • 1
  • 3
  • 11
14
votes
4 answers

Why onAppear called again after onDisappear while switching tab in TabView in SwiftUI?

I am calling API when tab item is appeared if there is any changes. Why onAppear called after called onDisappear? Here is the simple example : struct ContentView: View { var body: some View { TabView { NavigationView { …
Jay Patel
  • 2,642
  • 2
  • 18
  • 40
13
votes
2 answers

How to animate tabbar items (on selection) in SwiftUI?

How can I animate Tabbar Items (of a TabView) on selection in SwiftUI? for example give the selected item a .scaleEffect() with .spring() animation or sth like below: This is what I've tried so far: struct MyTabbedView: View { @State var…
Mehdi
  • 1,192
  • 1
  • 9
  • 21
12
votes
3 answers

Flutter tabview refresh issue

I have a TabBarView in my main.dart and every tab got a class to show the content(it's listview object), when i go between the tabs, the listview page refresh everytime, is it normal for tabbarview? I don't expect it will refresh everytime when i go…
Niccolo
  • 933
  • 4
  • 12
  • 17
11
votes
3 answers

SwiftUI TabView with PageTabViewStyle dynamic height based on Content

How do I make my SwiftUI TabView with a PageTabViewStyle adjust its height to the height of the content? I have a SwiftUI view like follows: struct TabViewDynamicHeight: View { var body: some View { VStack { TabView { …
Esera
  • 217
  • 2
  • 10
11
votes
3 answers

SwiftUI TabView: how to detect click on a tab?

I would like to run a function each time a tab is tapped. On the code below (by using onTapGesture) when I tap on a new tab, myFunction is called, but the tabview is not changed. struct DetailView: View { var model: MyModel @State var…
Daniele B
  • 19,801
  • 29
  • 115
  • 173
11
votes
2 answers

TabView with "PageTabViewStyle" does not update it's content when @State var changes

I came across a weird Issue in SwiftUI. I created a simple View that only holds a Button and a TabView that uses the PageViewStyle. It seems that the TabView does not update it's content correctly depending on the State of the Variable. It seems…
Sebastian Boldt
  • 5,283
  • 9
  • 52
  • 64
11
votes
1 answer

SwiftUI - Why is TabView and its contents sometimes not refreshing when I change tabs on macOS?

I'm trying to make a tabbed application on macOS with SwiftUI, and I have an odd issue with TabView. When I have two tabs with TextFields each and save their text states to their respective private variables, something odd happens: When I switch…
chungmcl
  • 310
  • 1
  • 3
  • 14
1
2 3
51 52