ios - Cell is being overzealously reused -


i have uicollectionviewcontroller , cells (uicollectionviewcell). want draw images on of cells. works fine, when scroll, of cells seems being unnecessarily reused, in other words cells didn't explicitly drawn on being drawn on (only after scrolling).

in cell following:

imageview = uiimageview(frame: cgrectmake((self.bounds.size.width/4)-1, (self.bounds.size.height/4)-1, 30, 30)); imageview!.image = imagetick self.addsubview(self.lblday) self.addsubview(imageview!) 

i create image view , set image add label , image view.

does see doing wrong?

just of case of completeness here how initialise images cell:

let imagetick:uiimage = uiimage(named: "star")! var imageview:uiimageview? = nil 

uicollectionviewcells reused system, need handle possibility of cell being reused in prepareforreuse method in uicollectionviewcell, clearing cell (setting image nil etc.)

here doc uicollectionreusableview declares that

here doc uicollectionview can see in doc, method dequeuereusablecellwithreuseidentifier:forindexpath: talks calling prepareforreuse if there available cell reuse.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -