Reputation: 1192
Has anyone else come across this incorrect behavior?
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)
}
}
}
Scroll the list to some item that is not initially visible.
Tap on the navaigationBar Title
Result: List scrolls to top.
Result: List does not scroll to top
I have filed feedback #FB9035540 on this. Just wondering if anyone else has experienced this and how they worked around it?
Upvotes: 2
Views: 673
Reputation: 30446
Actually, tapping the navigation bar's title has no effect in either portrait or landscape. What you came across is the behavior that happens when you tap the status bar.
From the documentation:
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.
The navigation bar's title and the status bar are very close together, so you probably thought it was the title that was doing the scroll.
In landscape mode, there is no status bar, so the gesture doesn't work.
Upvotes: 3