Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protocol MyCollectionViewCellDelegate {
- func didLongPressCell()
- }
- class MyCollectionViewCell:UICollectionViewCell {
- var delegate:MyCollectionViewCellDelegate?
- func longPressAction() {
- if let del = self.delegate {
- del.didLongPressCell
- }
- }
- }
- class MyViewController:UIViewController, MyCollectionViewCellDelegate {
- func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
- let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! MyCollectionViewCell
- cell.delegate = self
- return cell
- }
- func didLongPressCell() {
- // do what you want with the event from the cell here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement