Home How do I pass button action from a nested collectionView cell?
Reply: 0

How do I pass button action from a nested collectionView cell?

user5772
1#
user5772 Published in September 20, 2018, 5:20 pm

I have a MainCollectionView used for scrolling between items, inside of one of these cells I have another collectionView with cells. In that collection view, I have a button for each cell. My question is how do I pass action from my button to my MainCollectionView when it is tapped? I did create protocol for that button in the cell but I don't know how to let MainCollectionView know when my button is tapped. I can call action from my cell class but I think it is better to run it in Model which is my MainCollectionView. Below is my button protocol.

protocol ThanhCaHotTracksCellDelegate: class {
func handleSeeAllPressed()}

weak var delegate: ThanhCaHotTracksCellDelegate?


@objc func handleSeeAllButton(){
 delegate?.handleSeeAllPressed()
}
share|improve this question
  • you can use UIButton's addTarget(_ target: Any?, action: Selector, for controlEvents: UIControlEvents) method to add target/action for particular event of that button – Arnab Hore Feb 14 at 8:55

2 Answers 2

active oldest votes
up vote 0 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.332772 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO