I have gone through both
How to get the selected CollectionViewCell in the UICollectionView?
how to access from UICollectionViewCell the indexPath of the Cell in UICollectionView
But my question is little bit different from the above two.
I have review button on mybookingsCell which is from nearByCollectionView
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
DetailObject * Obj=[[DetailObject alloc]init];
Obj=[self.listOfObjects objectAtIndex:indexPath.row];
// DetailObject is NSObject class and listOfObjects getting values from API
// mybookingsCell.headerLabel.text=Obj.name; like this i am putting the values in cell
NearbyCell *mybookingsCell = (NearbyCell *)[cv dequeueReusableCellWithReuseIdentifier:@"nearby" forIndexPath:indexPath];
[mybookingsCell.reviewBtn addTarget:self action:@selector(didTapReviewBtn:) forControlEvents:UIControlEventTouchDown];
}
-(IBAction)didTapReviewBtn:(id)sender
{
}
On clicking review button i need details which are on the cell. I tried like this
-(IBAction)didTapReviewBtn:(id)sender
{
NearbyCell *clickedCell = (NearbyCell *)[[sender superview] superview];
NSIndexPath *clickedButtonIndexPath = [self.nearByCollectionView indexPathForCell:clickedCell];
}
But my application is crashing. So help me how can i fetch cell details with corresponding click on button.