[英]TabView in SwiftUI not responding
我正在嘗試使用 TabView 制作應用程序。 該應用程序呈現和運行良好,除了點擊選項卡沒有任何作用。
這是我的代碼,我錯過了什么嗎?
TabView {
HomeView()
.tabItem {
VStack {
Image(systemName: "1.circle")
Text("Home")
}
}.tag(1)
SecondView()
.tabItem {
VStack {
Image(systemName: "2.circle")
Text("SecondView")
}
}.tag(2)
}
我遇到了同樣的問題,最后發現我打開了可訪問性選項“全鍵盤訪問”。 關閉它可以修復它。
這是一個對我來說很好的最小示例:
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)
}
}
}
我希望這有幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.