I am trying to make an app using the TabView. The app renders and runs nicely, except for the fact that tapping on the tabs does nothing.
Here is my code, am I missing something?
TabView {
HomeView()
.tabItem {
VStack {
Image(systemName: "1.circle")
Text("Home")
}
}.tag(1)
SecondView()
.tabItem {
VStack {
Image(systemName: "2.circle")
Text("SecondView")
}
}.tag(2)
}
I had the same issue, in the end it turned out I had the accessibility option "Full keyboard access" turned on. Switching this off fixed it.
Here is a minimal example which works fine for me:
struct HomeView: View {
var body: some View {
Text("Home")
}
}
struct SecondView: View {
var body: some View {
Text("SecondView")
}
}
struct ContentView: View {
var body: some View {
TabView {
HomeView()
.tabItem {
VStack {
Image(systemName: "1.circle")
Text("Home")
}
}.tag(1)
SecondView()
.tabItem {
VStack {
Image(systemName: "2.circle")
Text("SecondView")
}
}.tag(2)
}
}
}
I hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.