作者:洛特大人_382 | 来源:互联网 | 2023-02-01 16:23
嗨...他们实际上是如何实现的?Twitter个人资料页面有一些教程。但是它们无法处理所有可能性...首先...当您在任何位置滚动顶部或底部时,顶视图开始滚动,直到分段控件到达页面顶部...然后滚动不会停止并且无法进行子表化开始滚动直到触及中途并且tableview中途开始动态加载其他行...所以我不认为它们静态设置了scrollview的内容
第二件事,他们如何处理子表...它们是containerView吗?如果是这样,那么结构将像这样
ScrollView
TopView (User Info)
Segmented Controll
scrollView(to swipe right or left changing tables)
ContainerView For TWEETS
ContainerView For TWEETS & REPLIES
ContainerView For MEDIA
ContainerView For LIKES
我对吗?因此,他们如何处理子表和“顶滚动视图”之间的滚动以实现基于滚动的顶视图位置更改...
令人不寒而栗
这就是我如何处理嵌套的ScrollViews ...我制作了childDidScroll协议,并且我的子tableviews实现了这一点,在我的个人资料页面中,我可以在childDidScroll方法中接收所有子didscroll事件:
//if child scrollview going up
if(scrollView.panGestureRecognizer.translation(in: scrollView.superview).y > 0)
{
//check top scrollview if it is at bottom or top
//then disable the current scrollview
if mainScrollView.isAtBottom && scrollView.isAtTop{
scrollView.isScrollEnabled = false
}else{
//else enable scrolling for my childs
featuresVC.tableView!.isScrollEnabled = true
categoriesVC.tableView!.isScrollEnabled = true
shopsVC.tableView!.isScrollEnabled = true
}
print("up")
}
else
{
if mainScrollView.isAtTop {
scrollView.isScrollEnabled = false
mainScrollView.scrollToBottom()
}else{
featuresVC.tableView!.isScrollEnabled = true
categoriesVC.tableView!.isScrollEnabled = true
shopsVC.tableView!.isScrollEnabled = true
}
print("down")
}
但是此解决方案有一些弊端...其中之一是,首先,当子滚动视图位于顶部或按钮上时,应该有两次尝试调用父滚动视图来处理滚动,首先尝试禁用子滚动视图,然后在第二次尝试父scrollview处理滚动
**我该怎么说,我的孩子何时向上滚动,检查父母是否在顶部,然后让他处理滚动;当他触摸底部时,您可以继续滚动,或者告诉父母scrollview,如果如果您或您的孩子正在滚动,则您位于顶部(用户信息可见),首先您要处理滚动,而当您处于底部富裕状态(用户信息不可见)时,让其余的滚动在您的孩子上**