ios - How to handle the event for the UICollectionView custom cell? -
i have created custom cell uicollectionview. custom cell has 2 uiimageview - imageview1 , imageview2.
how should handle event each imageview? can handle cell event on didselecteditemindex delegate of uicollectionview. want handle each imageview.
- (void)collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath *)indexpath { photosviewcell *cell = (photosviewcell*)[collectionview cellforitematindexpath:indexpath]; int tag1 = cell.imageview1.tag; int tag2 = cell.imageview2.tag; .... }
in cellforrowatindexpath method define tap gesture recognizer selector , assign image.
uitapgesturerecognizer *tapgesture = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(productimagetap:)]; [cell.imageview1 addgesturerecognizer:tapgesture]; [cell.imageview1 setuserinteractionenabled:yes]; [cell.imageview2 addgesturerecognizer:tapgesture]; [cell.imageview2 setuserinteractionenabled:yes];
then can want in productimagetap method. indexpath via locationinview method..
- (void)productimagetap:(uitapgesturerecognizer *)gesture { cgpoint point = [gesture locationinview:self.tableview]; nsindexpath *indexpath = [self.tableview indexpathforrowatpoint:point]; photosviewcell *cell = (photosviewcell *)[collectionview cellforitematindexpath:indexpath]; //do whatever want cell properties.. }
Comments
Post a Comment