Twitter个人资料页面iOS Swift剖析(UIScrollView中有多个UITableViews) [英] Twitter profile page iOS Swift dissection (Multiple UITableViews in UIScrollView)

查看:102
本文介绍了Twitter个人资料页面iOS Swift剖析(UIScrollView中有多个UITableViews)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...真的,他们是如何实现的? Twitter的个人资料页面有几个教程.但他们无法应付所有可能... 首先...当您在任何位置滚动顶部或底部时,顶视图开始滚动直到分段控件到达页面顶部...然后滚动不会停止并且子表开始滚动直到触摸下和中途tableview开始动态加载其他行...因此,我认为它们不会静态设置scrollview的内容

hi... really how do they implement this? there are several tutorial for Twitter profile page. but they don't handle all possibilities... first... when you scroll top or bottom any where, top view start scrolling until the segmented control, reach at top of the page...then scroll doesn't stop and subtable start scrolling until touching down and middle of way tableview start loading other rows dynamically ... so I don't think that they set content of scrollview statically

第二件事,它们如何处理子表...它们是containerView吗? 如果是这样,那么结构将是这样

second things how do they handle sub tables... are they containerView? if so, then the structure would be like this

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

我是对的吗? 因此,他们如何处理子表和顶部滚动视图"之间的滚动,以实现基于滚动的顶部视图位置更改...

am I right? so how do they handle scrolls between sub tables and Top Scroll View to implementing topview position change base on scrolling...

这真是令人震惊

这是我如何处理嵌套ScrollViews的方法... 我做了一个childDidScroll协议,我的子tableviews实现了这一点,在我的个人资料页面中,我可以接收到所有的child didscroll事件,然后在 childDidScroll方法:

this is How I Handel Nested ScrollViews... i made a childDidScroll Protocol and my child tableviews implement that and in my profile page i can receive all child didscroll event then in childDidScroll method :

   //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")
        }

但是此解决方案有一些弊端...其中之一是,首先当子滚动视图位于顶部或按钮时,应该有两次尝试调用父滚动视图处理滚动,首先尝试禁用子滚动滚动视图,然后在第二次尝试父滚动视图中处理滚动

but this solution has a some cons... and one of the is that first when child scrollview is at top or button, there should be two try to call my parent scrollview handle the scrolling, in first try i disable the child scrollview, and in second try parent scrollview handle the scrolling

**我怎么说,我的孩子何时向上滚动,检查父母是否在顶部,然后让他处理滚动;当他触摸底部时,您可以继续向上滚动,或者告诉父母scrollview,如果您位于顶部(用户信息可见),或者您或孩子正在向上滚动,则首先处理滚动,而当您位于底部(用户信息不可见)时,让其余的滚动显示您的孩子**

** how can i say when you , my child, scrolling up, check if your parent is at top, then let him handle the scroll and when he touching the bottom, you can handle remain up scrolling, or tell the parent scrollview , if you are at top (user info is visible) if you or your child getting up scrolling, first you handle the scroll and when you rich at bottom(user info is not visible), let the remain scrolling on you child**

推荐答案

我找到了一个库, https://github.com/maxep/MXSegmentedPager 完全正常

I found a library, https://github.com/maxep/MXSegmentedPager Its totally works fine

这篇关于Twitter个人资料页面iOS Swift剖析(UIScrollView中有多个UITableViews)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆