【问题标题】:Scroll vertical collection view along with whole view与整个视图一起滚动垂直集合视图
【发布时间】:2018-10-23 21:14:24
【问题描述】:

如链接上的图片所示,我有两个集合视图。我希望当我向上滚动垂直集合视图时,其他视图连同其顶部的水平集合视图一起滚动。我该怎么做?

The above image shows two collection views, the one on top is a horizontal collection view while the one on the bottom is a vertical collection view

【问题讨论】:

    标签: ios swift


    【解决方案1】:

    您可以在我刚刚提供的代码 sn-p 中执行类似操作...

    实现滚动视图委托方法...并根据滚动的集合视图,根据您的计算设置另一个的内容偏移量...

    let horizontalCollectionView = UICollectionView()
    let verticalCollectionView = UICollectionView()
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if scrollView == horizontalCollectionView {
            // set the content off set of the vertical collection view
        } else if scrollView == verticalCollectionView {
            // Set the content off set of horizontal collection view
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-07-25
      • 1970-01-01
      • 2017-01-11
      • 1970-01-01
      • 2019-08-03
      • 1970-01-01
      • 2017-07-30
      • 2014-07-13
      • 2015-12-21
      相关资源
      最近更新 更多