Created
August 10, 2016 16:23
-
-
Save Wouter125/3c0a165cccf623e05a7b02b38be26cf9 to your computer and use it in GitHub Desktop.
Collectionview Cell detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func buildCollectionView() { | |
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() | |
layout.scrollDirection = .horizontal | |
layout.minimumInteritemSpacing = 0; | |
layout.minimumLineSpacing = 4; | |
collectionView = UICollectionView(frame: CGRect(x: 0, y: screenSize.midY - 120, width: screenSize.width, height: 180), collectionViewLayout: layout) | |
collectionView.dataSource = self | |
collectionView.delegate = self | |
collectionView.register(VideoCell.self, forCellWithReuseIdentifier: "videoCell") | |
collectionView.showsHorizontalScrollIndicator = false | |
collectionView.showsVerticalScrollIndicator = false | |
collectionView.contentInset = UIEdgeInsetsMake(0, 20, 0, 30) | |
collectionView.backgroundColor = UIColor.white() | |
collectionView.alpha = 0.0 | |
collectionView.layer.masksToBounds = false | |
collectionView.clipsToBounds = false | |
collectionView.isUserInteractionEnabled = true | |
//adding gesturerecognizer to the complete view | |
swipeUpRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.deleteCell)) | |
swipeUpRecognizer.delegate = self | |
self.view.addGestureRecognizer(swipeUpRecognizer) | |
} | |
func deleteCell(sender: UIPanGestureRecognizer) { | |
let tapLocation = sender.location(in: self.view) | |
let indexPath = self.collectionView.indexPathForItem(at: tapLocation) | |
print(indexPath) //only prints when I'm at 0 - 180. But as you can see from my collectionView it starts at the center of the screen - 120 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment