Refresh icon indicating copy to clipboard operation
Refresh copied to clipboard

上拉加载出现异常

Open toutyeung opened this issue 4 years ago • 8 comments

你好 我将FooterRefresh属性添加到ScrollView上,但是View在最底部. 没有上拉到一定高度,切换到其他View的时候,updata函数出现nil错误.

func update(proxy: GeometryProxy, value: Refresh.FooterAnchorKey.Value) { guard let item = value.first else { return } guard headerUpdate.progress == 0 else { return }

    let bounds = proxy[item.bounds]

在取得bounds的时候出现nil错误

toutyeung avatar Apr 22 '20 13:04 toutyeung

你好,你说添加到 ScrollView 上,是这样吗?

List {
    ScrollView {
        RefreshFooter(refreshing: $footerRefreshing, action: {
            ...
        })
    }
}
.enableRefresh()

我没能复现出错误,能提供一下复现错误的条件或者代码吗?

wxxsw avatar Apr 22 '20 21:04 wxxsw

我没有重写代码,只是把上拉下拉加载的属性直接添加到ScrollView上

ScrollView{

VStack{

    View1()
    View2()
    View3()
    View4()
    View5()
    RefreshFooter(refreshing: $footerRefreshing, action: {
        ...
    })
}

}.modifier(Refresh.Modifier(enable: true))

加载后的数据是添加到View5里面,但是没有显示View5时候,切换到其他View就会有错误 但是,只有View1的时候是没有问题的

toutyeung avatar Apr 23 '20 06:04 toutyeung

😅原来你这么用的,我一直都是为 List 开发的,还没有适配过 ScrollView,所以也没添加 ScrollView 的扩展,我周末有时间试下,如果方便的话,我会适配一下

wxxsw avatar Apr 23 '20 07:04 wxxsw

我也用过你的方法,把ScrollView放在List里,然后给List添加enableRefresh属性,还是同样的错误.

下面这个没有问题

ScrollView{

VStack{

View1()
RefreshFooter(refreshing: $footerRefreshing, action: {
    ...
})

} }.modifier(Refresh.Modifier(enable: true))

toutyeung avatar Apr 23 '20 07:04 toutyeung

放到 List 里面的时候,不嵌套 VStack 试下呢?

wxxsw avatar Apr 23 '20 07:04 wxxsw

还是同样的错误。

toutyeung avatar Apr 24 '20 01:04 toutyeung

你好,我也遇到了同样的错误,请问有解决方法吗?

HT0799 avatar Nov 13 '20 05:11 HT0799

能否提供一个可以复现错误的小 Demo(可以上传到你自己的 Github 上,或者发到我的邮箱 [email protected])。我收到后,明后天会解决一下。

wxxsw avatar Nov 13 '20 05:11 wxxsw