【发布时间】:2023-03-25 07:10:01
【问题描述】:
我通过引用https://developer.apple.com/documentation/swiftui/tabview 使用SwiftUI 框架实现TabbedView
在模拟器上运行时,只显示第一个选项卡视图内容,其他选项卡内容不显示。即使在重新启动 XCode、模拟器等之后。
应用视频链接:https://youtu.be/Gibu8jfQQ5I
struct ContentView : View {
var body: some View {
TabbedView {
Text("The First Tab")
.tabItem {
Image(systemName: "1.square.fill")
Text("First")
}
Text("Another Tab")
.tabItem {
Image(systemName: "2.square.fill")
Text("Second")
}
Text("The Last Tab")
.tabItem {
Image(systemName: "3.square.fill")
Text("Third")
}
}.font(.headline)
}
}
感谢您的帮助和建议!
【问题讨论】:
-
尝试将
.padding()添加到TabbedView。 -
嗯,我使用了相同的代码,它在模拟器和预览选项卡上运行良好。我正在使用 beta 5。您也可以尝试删除并重新添加模拟器。
标签: ios swiftui tabbed-view