SwiftUI:点击横向列表中的导航栏不会将列表滚动到顶部
SwiftUI: Tapping navigation bar in landscape list does not scroll list to top
还有其他人遇到过这种不正确的行为吗?
- 使用以下代码创建应用程序:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
ForEach (0..<100, id:\.self) { index in
Text("Hello, \(index)!")
.padding()
}
}
.navigationBarTitle("Test", displayMode: .inline)
}
}
}
将列表滚动到最初不可见的某个项目。
点击导航栏标题
结果:列表滚动到顶部。
- 在横向模式下使用 iPhone 尝试同样的操作。
结果:列表没有滚动到顶部
我已就此提交反馈#FB9035540。只是想知道是否有其他人遇到过这种情况以及他们是如何解决的?
实际上,点击导航栏的标题在纵向 或 横向中都没有效果。您遇到的是点击状态栏时发生的行为。
The scroll-to-top gesture is a tap on the status bar. When a user makes this gesture, the system asks the scroll view closest to the status bar to scroll to the top.
导航栏的标题和状态栏靠得很近,所以您可能认为是标题在滚动。
在横向模式下,没有状态栏,所以手势不起作用。
还有其他人遇到过这种不正确的行为吗?
- 使用以下代码创建应用程序:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
ForEach (0..<100, id:\.self) { index in
Text("Hello, \(index)!")
.padding()
}
}
.navigationBarTitle("Test", displayMode: .inline)
}
}
}
将列表滚动到最初不可见的某个项目。
点击导航栏标题
结果:列表滚动到顶部。
- 在横向模式下使用 iPhone 尝试同样的操作。
结果:列表没有滚动到顶部
我已就此提交反馈#FB9035540。只是想知道是否有其他人遇到过这种情况以及他们是如何解决的?
实际上,点击导航栏的标题在纵向 或 横向中都没有效果。您遇到的是点击状态栏时发生的行为。
The scroll-to-top gesture is a tap on the status bar. When a user makes this gesture, the system asks the scroll view closest to the status bar to scroll to the top.
导航栏的标题和状态栏靠得很近,所以您可能认为是标题在滚动。
在横向模式下,没有状态栏,所以手势不起作用。