ios - UICollectionView is showing but the cells are not showing in swift -


i created collectionview programmatically (without storyboard). set background color red, , showing properly. cells not showing. know why cells not showing?

private let cellid = "cellid" class infoviewshow: nsobject, uicollectionviewdatasource, uicollectionviewdelegate, uicollectionviewdelegateflowlayout { private let cellheight:cgfloat = 80  var collectionview: uicollectionview? let layout = uicollectionviewflowlayout()  override init() {     super.init()      setupcollectionview()      collectionview?.registerclass(infocell.self, forcellwithreuseidentifier: cellid) }  private func setupcollectionview() {     if let view = uiapplication.sharedapplication().keywindow {         //let y = (view.frame.width * 10 / 16) + 34 + 26         collectionview = uicollectionview(frame: .zero , collectionviewlayout: layout)         collectionview?.backgroundcolor = uicolor.redcolor()         collectionview?.delegate = self         collectionview?.datasource = self         collectionview?.frame = cgrectmake(0, 0, view.frame.width, view.frame.height) // y y     } }  func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int {     return 3 }  func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {     let cell = collectionview.dequeuereusablecellwithreuseidentifier(cellid, forindexpath: indexpath)     cell.backgroundcolor = uicolor.blackcolor()     return cell }  func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize {     return cgsizemake(collectionview.frame.width, cellheight) }  func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, insetforsectionatindex section: int) -> uiedgeinsets {     return uiedgeinsetsmake(5, 5, 5, 5); //top,left,bottom,right } } 

i dont' see add collectionview view.

if let view = uiapplication.sharedapplication().keywindow {         //let y = (view.frame.width * 10 / 16) + 34 + 26         collectionview = uicollectionview(frame: .zero , collectionviewlayout: layout)         collectionview?.backgroundcolor = uicolor.redcolor()         collectionview?.delegate = self         collectionview?.datasource = self         collectionview?.frame = cgrectmake(0, 0, view.frame.width, view.frame.height) // y y          ///try add         self.view.addsubview(collectionview)     } 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -