【发布时间】:2016-08-11 17:04:38
【问题描述】:
我有一个 UICollectionView,我想向它的单元格/项目添加平移手势。当我以通常的方式添加手势时,UICollectionView 没有滚动。
这就是我添加手势的方式
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell:UICollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath)
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(CaptureViewController.pagesCollectionViewItemPanEvent(_:)))
cell.addGestureRecognizer(panGesture)
return cell;
}
这里有什么问题吗?有人可以告诉我完成工作的方法吗?任何帮助将不胜感激。
【问题讨论】:
-
查看这个答案,希望对您有所帮助:) Swift gesture
-
尝试扩展您的集合视图对象,从那里实现 touchesbegan 触摸事件方法。然后处理你的pan事件,然后实现[super touchevents]方法,这样现有的collectionview滚动就不会影响了。
标签: ios swift uicollectionview uipangesturerecognizer