gpt4 book ai didi

ios - UICollectionView 滑动

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:50:12 27 4
gpt4 key购买 nike

我想检测用户何时在一个单元格占据整个屏幕宽度的 collectionView 中向左或向右滑动。是否可以不添加手势识别器。我试过添加手势识别器,但只有当我们将 collectionView 的 scrollEnabled 属性设置为 NO 时它才有效。

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
swipeRight.delegate = self;
swipeRight.numberOfTouchesRequired = 1;
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];

UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeLeft:)];
swipeLeft.delegate = self;
swipeLeft.numberOfTouchesRequired = 1;
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];

[self.collectionView addGestureRecognizer:swipeLeft];
[self.collectionView addGestureRecognizer:swipeRight];

最佳答案

也许您禁用了 userInteraction。你检查了吗?并将手势定义为类的属性。

self.collectionView.setUserInteractionEnabled=true;

关于ios - UICollectionView 滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27814198/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com