CollectionView cell contentView touches outside of bounds

时间:2015-09-14 15:59:22

标签: ios objective-c uicollectionview uicollectionviewcell

I have a custom collectionView cell in a basic collectionView with a FlowLayout. When the user selects a cell, I set the contentView clipsToBounds to NO and I add a button to the contentView of the cell that is outside of the cell bounds, covering a neighbour collectionView cell (this is ok, it's part of the design, not a bug).

When I tap the button it doesn't capture the touch events. Instead, the collectionView didSelectItemAtIndexPath method is called. Is there any way of having the button capture the touch events, even if it's outside the bounds of the cell?

Edit: In case it helps, an example:

cell.contentView frame: (0, 0, 100, 100)
cell.button frame: (100, 40, 50, 20)

As you can see, the button it outside the bounds of the contentView. Instead of calling the button tap selector, the button tap triggers the - collectionView:didDeselectItemAtIndexPath: method of my UICollectionViewDelegate.

0 个答案:

没有答案