import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
ForEach(0..<10) { number in
ListViewInsideControllerRepresentable() // Scroll To Top doesn't work if its being used.
//ListView() // Scrolls to top works if it's being used.
.ignoresSafeArea(.all)
.tag(number)
}
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
}
}
#Preview {
ContentView()
}
struct ListView: View {
var body: some View {
List {
Text("ASD1")
Text("ASD2")
Text("ASD3")
Text("ASD4")
Text("ASD1")
Text("ASD2")
Text("ASD3")
Text("ASD4")
Text("ASD1")
Text("ASD2")
Text("ASD3")
Text("ASD4")
Text("ASD1")
Text("ASD2")
Text("ASD3")
Text("ASD4")
Text("ASD1")
Text("ASD2")
Text("ASD3")
Text("ASD4")
Text("ASD1")
Text("ASD2")
Text("ASD3")
Text("ASD4")
}
}
}
struct ListViewInsideControllerRepresentable: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
return UIHostingController(rootView: ListView())
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
print("Update")
}
}