ios - UICollectionView cell.ViewWithTag returning nil for UILabel -


this label seems return nil, though have reuseidentifier , tag set properly.

override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {     var identifier: string = "collectioncell"     var cell: uicollectionviewcell = collectionview.dequeuereusablecellwithreuseidentifier(identifier, forindexpath: indexpath) as! uicollectionviewcell      // configure cell       //save till later, when images present      //var cellitem1 = hostmanager[indexpath.row * 2]      let label:uilabel = cell.viewwithtag(1) as! uilabel     return cell  } 

the program breaks label set = viewwithtag. have no custom class set cell, prototype. tag set on storyboard. getting error "exc_bad_instruction...". appreciated, thanks!

try removing line viewdidload:

self.collectionview!.registerclass(uicollectionviewcell.self, forcellwithreuseidentifier: reuseidentifier) 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -