0

I have different views and I can reach them via TabView. My goal is detecting clicks on tabview. If I click on them twice I want to refresh the screen with new updated data. Here is the sample code. Where should I put the code?

TabView {
  Text("The First Tab")
    .tabItem {
      Label("First", systemImage: "1.square.fill")
    }
  
  Text("The Second Tab")
    .tabItem {
      Label("Second", systemImage: "2.square.fill")
    }
  
  Text("The Third Tab")
    .tabItem {
      Label("Third", systemImage: "3.square.fill")
    }
}
neco
  • 23
  • 4
  • We can use `TabView(selection:` for this purpose, like in https://stackoverflow.com/a/64020773/12299030 or in https://stackoverflow.com/a/60691250/12299030. – Asperi Nov 02 '21 at 16:42
  • Thanks for the answer. I want to detect click on same tab. If I am in the second tab and when I click it I want to print something for every click on the same tab. – neco Nov 02 '21 at 17:41
  • Does putting `.onTapGesture(count: 2)` on `Label` work? – eXCore Nov 02 '21 at 18:41

0 Answers0