When I tap Cell in CollectionView, I am trying to implement the process such as adding subView to Cell like the camera roll in the Twitter app.
That's why I wrote this.
-(CameraRollCell*)collectionView:(UICollectionView*)collectionViewcellForItemAtIndexPath:(NSIndexPath*)indexPath{
CameraRollCell* cell= [collectionView requestReusableCellWithReuseIdentifier: cellID forIndexPath:indexPath];
return cell;
}
- (void) collectionView: (UICollectionView*) collectionView didSelectItemAtIndexPath: (NSIndexPath*)indexPath{
CameraRollCell*cell= [collectionView cellForItemAtIndexPath:indexPath];
cell selectPhoto;
}
US>Preparing a custom class inherited from the UICollectionViewCell` and retrieving the cell when tapped.After retrieval, you are invoking a method to add the subView that the custom cell has.
However, cellForItemAtIndexPath:
will probably not be able to retrieve custom class Cells, so it will play...
So I have a question.
I look forward to hearing from you.
Supplemental
- I do not use StoryBoard.Code-only implementation.
in viewDidLoad
[self.collectionViewregisterClass:[CameraRollCell class] Added forCellWithReuseIdentifier:cameraRollCellID; and it worked fine.
Thank you for your comment.
© 2025 OneMinuteCode. All rights reserved.