scrollToRow(at:at:animated :) SwiftUI

问题描述 投票:0回答:1

我有List有100个项目我想滚动到项目编号20如何在SwiftUI

中实现

这是我简单的ListCode

struct ContentView: View {
    var body: some View {
        List {
            Button(action: {
                self.scrollToIndex(index: 20)
            }) {
                Text("Scroll To 20")
            }
            ForEach(0..<100) {_ in
                Text("Hello World")
            }
        }
    }

    func scrollToIndex(index: Int) {

    }
}
ios swiftui
1个回答
0
投票

[较早的人试图为此answering here找到一些解决方案。不久:今天(2019年11月),除了使用ScrollViewUITableView(最后一个UIViewControllerRepresentable)之外,我没有找到任何解决方案

<< [update从9月开始发现Apple Developer Forums thread并有此问题,但仍无答案

© www.soinside.com 2019 - 2024. All rights reserved.