每当我将设备旋转到横向并再次返回时,顶部NavigationView
(包括标题和后退按钮)被剪切在状态栏下方。
最小可重现示例:
struct ContentView: View {
var body: some View {
NavigationView {
ScrollView {
VStack {
ForEach(0..<15) { _ in
Text("Filler")
.frame(maxWidth: .infinity)
.background(Color.green)
.padding()
}
}
}
.navigationBarTitle("Data")
}
}
}
只要内容是可滚动的,就会出现故障。我最初在使用时遇到了这个List
。如果我先单击一行,转到弹出视图,然后旋转设备,这并不重要,or刚刚旋转回到主屏幕。
struct ContView: View {
let data = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen"]
var body: some View {
NavigationView {
List {
ForEach(data, id: \.self) { word in
NavigationLink(destination:
Text("Link")
) {
Text(word)
}
}
}
.navigationBarTitle("Data", displayMode: .large)
.listStyle(InsetGroupedListStyle())
}
}
}
Rotating in the main screen |
Rotating after tapping a row |
|
|
这是一个错误,还是我做错了什么?我还在控制台中打印了这个:
2020-10-19 09:05:30.613243-0700 MyAppName[43106:5613320] 对 TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVVS_22_VariadicView_Children7ElementGVS_18StyleContextWriterVS_19SidebarStyleContext__:0x10340c180>。
Xcode 版本:12.0 (12A7209),在运行 iOS 14.0 的 iPhone 7 Plus 上运行