Twitter个人资料页面iOSSwift剖析(UIScrollView中的多个UITableView)
Twitter profile page iOS Swift dissection (Multiple UITableViews in UIScrollView)
嗨...他们是如何实施的?有几个 Twitter 个人资料页面的教程。但他们并没有处理所有的可能性......
首先......当你滚动顶部或底部的任何地方时,顶视图开始滚动直到分段控件,到达页面顶部......然后滚动不会停止并且子表开始滚动直到触及中间并且表格视图开始动态加载其他行...所以我不认为他们静态设置滚动视图的内容
第二件事他们如何处理子表...他们是 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
我说的对吗?
那么他们如何处理子表和顶部滚动视图之间的滚动以实现基于滚动的顶部视图位置更改...
令人兴奋
这就是我如何使用 Handel 嵌套 ScrollViews...
我做了一个 childDidScroll 协议,我的 child tableviews 实现了它,在我的个人资料页面中,我可以接收所有 child didscroll 事件,然后在
childDidScroll 方法:
//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")
}
但是这个解决方案有一些缺点...其中一个是首先当 child 滚动视图位于顶部或按钮时,应该有两次尝试调用我的 parent 滚动视图句柄滚动,第一次尝试禁用 child 滚动视图,第二次尝试 parent 滚动视图处理滚动
** 我怎么说当你,我的 child,向上滚动,检查你的 parent 是否在顶部,然后让他处理滚动,当他触摸底部时,你可以处理保持向上滚动,或者告诉 parent scrollview ,如果你在顶部(用户信息可见)如果你或你的 child 起床滚动,首先你处理滚动,当你富有时底部(用户信息不可见),让您保持滚动 child**
我相信你大部分是对的,除了最上面的滚动视图。
在最近的一个应用程序中,我在 tutorial:
之后实现了类似的东西
基本上,诀窍是让 class 成为底部 UITableView
的滚动委托,监听 scrollViewDidScroll
修改,并修改 class 的顶部插入=11=] 和 TopView
.
我要使用的结构是这样的:
Topview
ScrollView (horizontal scroll)
Segmented Control
ScrollView (horizontal, paging scroll)
UITableView
UITableView
UITableView
UITableView
你是完全正确的,令人兴奋。看起来很简单。
我找到了一个图书馆,
https://github.com/maxep/MXSegmentedPager
完全可以正常工作
经过长时间的调查,这就是我实现 Twitter 个人资料行为的方式。
- UnderlayScrollView
- MasterScrollView
- Header ViewController
- 底部 ViewController
- PagerTabItems [集合视图]
- UIPagerController 或任何其他水平滚动条(Parchment、XLPagerTabStrip)。
UnderlayScrollView负责控制滚动手势。它的 contentoffset 用于调整内部滚动 contentOffsets。底层卷轴的内容大小与主卷轴的内容大小相同。
有关更多信息,请参阅 github 上的源代码。 click
嗨...他们是如何实施的?有几个 Twitter 个人资料页面的教程。但他们并没有处理所有的可能性...... 首先......当你滚动顶部或底部的任何地方时,顶视图开始滚动直到分段控件,到达页面顶部......然后滚动不会停止并且子表开始滚动直到触及中间并且表格视图开始动态加载其他行...所以我不认为他们静态设置滚动视图的内容
第二件事他们如何处理子表...他们是 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
我说的对吗? 那么他们如何处理子表和顶部滚动视图之间的滚动以实现基于滚动的顶部视图位置更改...
令人兴奋
这就是我如何使用 Handel 嵌套 ScrollViews... 我做了一个 childDidScroll 协议,我的 child tableviews 实现了它,在我的个人资料页面中,我可以接收所有 child didscroll 事件,然后在 childDidScroll 方法:
//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")
}
但是这个解决方案有一些缺点...其中一个是首先当 child 滚动视图位于顶部或按钮时,应该有两次尝试调用我的 parent 滚动视图句柄滚动,第一次尝试禁用 child 滚动视图,第二次尝试 parent 滚动视图处理滚动
** 我怎么说当你,我的 child,向上滚动,检查你的 parent 是否在顶部,然后让他处理滚动,当他触摸底部时,你可以处理保持向上滚动,或者告诉 parent scrollview ,如果你在顶部(用户信息可见)如果你或你的 child 起床滚动,首先你处理滚动,当你富有时底部(用户信息不可见),让您保持滚动 child**
我相信你大部分是对的,除了最上面的滚动视图。
在最近的一个应用程序中,我在 tutorial:
之后实现了类似的东西基本上,诀窍是让 class 成为底部 UITableView
的滚动委托,监听 scrollViewDidScroll
修改,并修改 class 的顶部插入=11=] 和 TopView
.
我要使用的结构是这样的:
Topview
ScrollView (horizontal scroll)
Segmented Control
ScrollView (horizontal, paging scroll)
UITableView
UITableView
UITableView
UITableView
你是完全正确的,令人兴奋。看起来很简单。
我找到了一个图书馆, https://github.com/maxep/MXSegmentedPager 完全可以正常工作
经过长时间的调查,这就是我实现 Twitter 个人资料行为的方式。
- UnderlayScrollView
- MasterScrollView
- Header ViewController
- 底部 ViewController
- PagerTabItems [集合视图]
- UIPagerController 或任何其他水平滚动条(Parchment、XLPagerTabStrip)。
UnderlayScrollView负责控制滚动手势。它的 contentoffset 用于调整内部滚动 contentOffsets。底层卷轴的内容大小与主卷轴的内容大小相同。
有关更多信息,请参阅 github 上的源代码。 click