Getting button action : UICollectionView Cell

2019-01-13 16:15发布

I have created a UICollectionViewCell by nib and added a button inside it and created a .h and .m files added the class to the nibs file's owner.then wrote a button action in the .m connected it via outlet.

The collection view is populating fine ,but cannot get the buton action triggered. I think the delegate for collection cell is called.

How can i get the button action?

7条回答
地球回转人心会变
2楼-- · 2019-01-13 16:49

I feel hard to understand the Accepted answer, I will try to give a simple answer.

In UICollectionViewCell there are two types.

  1. Collection View Cell
  2. Collection Reusable View

I used the Collection Reusable View, in that the button actions are not working.

Then as per the accepted answer i tried to use the Collection View Cell, in that only the Button Actions are Working. Use the second object in the Image. It will work fine.

enter image description here

查看更多
登录 后发表回答