列表视图,所选项目的隐藏行更改位置?

时间:2019-12-21 19:57:32

标签: swiftui swiftui-list

listPhoto

var body: some View {

class MyItemClass {
    var item = "random string". <-- after reusult
}
var arrayItem = [MyItemClass] // count 100 over

HStack {
        Button("favorite item") {
         // suppose button action work 50th row locate in top of view... current view not show 50th row because of below row...
         }
        List{
             ForEach(self.arrayItem, id: \self) { item in
                 Text("\(item.item)")
             }
        }
}

我的代码手动滚动列表视图以显示选定的项目行...

我希望所选项目的行位置在列表顶部或中心。

在代码上方,单击按钮,然后在“视图”中显示第50行。

当前,我滚动视图以显示第50行。

我希望不要滚动,而是通过单击按钮自动移动第50行。

那怎么做?

0 个答案:

没有答案