ios - Why I cannot assign image to custom collect CollectionViewCell -
i designed custom uicollectionviewcell
, added image view outlet. then, connected image view cell. somehow, cannot assign image (uiimage)
image view. below code cellforitematindexpath
.
- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { // service gallary custom collection view cell. [self.collectionview registerclass:[servicegallarycell class] forcellwithreuseidentifier:collectioncellidentifier]; servicegallarycell *servicecollectioncell = (servicegallarycell*)[collectionview dequeuereusablecellwithreuseidentifier:collectioncellidentifier forindexpath:indexpath]; if (collectionview == self.collectionview) { servicecollectioncell.image.image = [uiimage imagenamed:_imagesarray[indexpath.row]]; } return servicecollectioncell; }
you can try:
-(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { static nsstring *collectionviewidentifier = @"cellidentifier"; servicegallarycell *cell = [collectionview dequeuereusablecellwithreuseidentifier:collectionviewidentifier forindexpath:indexpath]; cell.imageview.image = _imagesarray[indexpath.row]; return servicecollectioncell; }
Comments
Post a Comment