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")
    }
}
3
  • We can use TabView(selection: for this purpose, like in stackoverflow.com/a/64020773/12299030 or in stackoverflow.com/a/60691250/12299030. Commented Nov 2, 2021 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. Commented Nov 2, 2021 at 17:41
  • Does putting .onTapGesture(count: 2) on Label work? Commented Nov 2, 2021 at 18:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.