I have a UITableview
. One of the UITableViewCell's
is a UICollectionview
with instance name "amenityView". The UICollectionViewDelegate
and the UICollectionViewDataSource
are set in the storyboard
as shown below. The following methods get called and the data is populated as expected.
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (UICollectionViewCell *)collectionView:(UICollectionView *)collection cellForItemAtIndexPath:(NSIndexPath *)indexPath
However, the methods below didn't get called when I select the UICollectionViewCell
contained in the UICollectionView
. What have I missed?
-(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
-(void) collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
UPDATE:
return YES in this method collectionView:shouldSelectItemAtIndexPath:
will invoke the below two methods. At least that's what was missing on my part. Hope this will help some body...
Does the table view's didSelectRowAtIndexPath get called? If so, the table view may be intercepting the touches and not passing them through to the collection view inside. I've never done the solution you are trying to do, but the collection view is inside a scroll view, and it may not be easy to pass the touch info along to the collection view in a way that makes sense, so you may need to disable tapping on the table view cell in order for the collection view to respond to touches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With