Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. protocol MyCollectionViewCellDelegate {
  2. func didLongPressCell()
  3. }
  4.  
  5. class MyCollectionViewCell:UICollectionViewCell {
  6.  
  7. var delegate:MyCollectionViewCellDelegate?
  8.  
  9. func longPressAction() {
  10. if let del = self.delegate {
  11. del.didLongPressCell
  12. }
  13. }
  14.  
  15. }
  16.  
  17. class MyViewController:UIViewController, MyCollectionViewCellDelegate {
  18.  
  19. func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
  20. let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! MyCollectionViewCell
  21. cell.delegate = self
  22. return cell
  23. }
  24.  
  25. func didLongPressCell() {
  26. // do what you want with the event from the cell here
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement