Wednesday, 15 September 2010

ios - How to get the selected CollectionViewCell in the UICollectionView? -



ios - How to get the selected CollectionViewCell in the UICollectionView? -

i new ios development , , seek utilize uicollectionview show photo without using storyboard.

i create xib file phone call aitfilecell_grid.xib , , add together collection view cell.

i create xib file , add together collection view loading collection view cell.

i want selected multiple file , delete them delete button.

but can not cell when click delete button next code.

if(self.collectionview.indexpathsforselecteditems > 0){ nslog(@"indexpathsforselecteditems...count.%@..@@@" , self.collectionview.indexpathsforselecteditems); for(nsindexpath *indexpath in self.collectionview.indexpathsforselecteditems){ // [self.collectionview deselectitematindexpath:indexpath animated:no]; nsstring *filepath = [nsstring stringwithformat:@"%@/%@", directory, [filelist objectatindex:indexpath.row]]; [[nsfilemanager defaultmanager] removeitematpath:filepath error:nil] ; aitfilecell_grid *cell = [self.collectionview dequeuereusablecellwithreuseidentifier:@"aitfilecell_grid" forindexpath:indexpath]; } }

but sell seems not correct...

how selected cell in collectionview ?

for checking collection cell clicked, can utilize delegate method in controller.

-(void)collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath *)indexpath { int itemno = (int)[indexpath row]+1; collectioncell *selectedcell =(collectioncell*)[collectionview cellforitematindexpath:indexpath]; switch (itemno) { case 1: { //your logic 1st cell break; } case 2: { //your logic 2nd cell break; } . . . } }

ios objective-c uicollectionview uicollectionviewcell

No comments:

Post a Comment