ios - 'UICollectionViewCell' does not have a member named 'image' [Swift] -


i'm setting project uicollectionview displays image label. created viewcontroller , cellviewcontroller, supposed to.

in cellviewcontroller code following:

class cellcontroller: uicollectionviewcell {      @iboutlet weak var image: uiimageview!     @iboutlet weak var label: uilabel!   } 

but in viewcontroller when i'm setting image gives me error. here's code:

func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {      let cell: uicollectionviewcell = collection.dequeuereusablecellwithreuseidentifier("cell", forindexpath: indexpath) as! cellcontroller      cell.image.image = uiimage(named: "star")      return cell } 

and weirdest thing is, have project downloaded github same mine, , works fine.

thanks in advance!

your problem :uicollectionviewcell. although cast cell cellcontroller makes type uicollectionviewcell, not have image property. removing or replacing cellcontroller fix problem.

let cell = collection.dequeuereusablecellwithreuseidentifier("cell", forindexpath: indexpath) as! cellcontroller 

i consider renaming image view imageview. there's line cell.image.image doesn't right!


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -