ios - Hiding UICollectionViewCell -


i'm trying hide uicollectionviewcell in collection view. although i'm successful when do

cell.hidden = yes; //or cell.alpha = 0.0; 

but after scroll cell appears again. i've tried following:

uicollectionviewlayoutattributes *layoutattr = <get layout attribute>//i'm succesfull here layout.hidden = yes; [cell applylayoutattributes:layoutattr]; 

i thought might because i'm using dequereusable.. method , hence cell being re used, have tried hide cell in collectionview:cellforitematindexpath: method no avail. here doesn't seem work.

why not working? how can hide uicollectionviewcell?

edit: included implementation of collectionview:cellforitematindexpath::

-(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath{      static nsstring *identifier = @"cell";      uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:identifier forindexpath:indexpath];     cell.layer.cornerradius  = 12.0f;     cell.backgroundcolor = [uicolor colorwithred:0.830 green:0.899 blue:1.000 alpha:1.000];      cell.selectedbackgroundview = [[uiview alloc]initwithframe:cell.frame];     cell.selectedbackgroundview.backgroundcolor = [uicolor lighttextcolor];;     cell.layer.bordercolor = [uicolor blackcolor].cgcolor;     cell.layer.borderwidth = 2.0f;     cell.hidden = yes;     uilabel *lbl = (uilabel *)[cell viewwithtag:10];     nsarray *interarray = numberarray[indexpath.section];     [lbl settext:[interarray[indexpath.row] stringvalue]];      return cell;    } 

this should hide cells right? nope, doesn't happen.

since hiding cell doesn't seem work, can either add subview cell same color collection view's background color, or can hide cell's content view, work:

cell.contentview.hidden = yes; cell.backgroundcolor = self.collectionview.backgroundcolor; 

that second line necessary if have set background color cell.


Comments