简体   繁体   English

iOS-对视图中的多个Tableview或CollectionView使用/传递手势识别器(Swift)

[英]iOS - Use/pass gesture recognizer for multiple Tableviews or Collectionviews in a View(Swift)

I've got 2 (circular) UICollectionviews in my view, both are functioning but I want to use 1 swipe gesture for both views so when I swipe on the top collectionview, the bottom view should also swipe with the same speed and vice-versa. 我的视图中有2个(圆形)UICollectionviews,两个都可以,但是我想对两个视图使用1个滑动手势,因此当我在顶部collectionview上滑动时,底部视图也应以相同的速度滑动,反之亦然。 What would be the best way to achieve this? 实现这一目标的最佳方法是什么?

This is my UIViewController: 这是我的UIViewController: 2通函集合视图

both collectionviews should scroll whenever I scroll anywhere on this UIViewController. 每当我在此UIViewController上的任何位置滚动时,两个collectionviews都应滚动。 Any help would be very appreciated. 任何帮助将不胜感激。

Set scrollView delegate of your collectionView's scrollView . 设置collectionView的scrollView scrollView delegate UICollectionView is a subclass of UIScrollView . UICollectionViewUIScrollView的子类。 Use scrollViewDidScroll method. 使用scrollViewDidScroll方法。 In that method you can for example see contentOffset of one UICollectionView and then set contentOffset to the other collectionView's scrollView to that value. 例如,在该方法中,您可以查看一个UICollectionView contentOffset ,然后将contentOffset设置为另一个collectionView's scrollView值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM