我有一個UICollectionView,我想將平移手勢添加到它的Cells/Items。當我以通常的方式添加手勢UICollectionView沒有滾動。將平移手勢添加到UICollectionView單元 - IOS/Swift
這是我的錯在這裏添加手勢
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;
}
有什麼事?有人可以告訴我一種方法來完成我的工作。任何幫助將不勝感激。
檢查這個答案我希望它幫你:) [斯威夫特的手勢(http://stackoverflow.com/a/18848817/6628878) –
嘗試擴展您的收藏視圖對象從,有實現觸摸開始觸摸事件的方法。然後處理您的pan事件,然後實現[super touchevents]方法,以便現有的collectionview滾動不會產生影響。 – Bharath