ios - UICollectionView Cells not shown if UITabBarController is on second tab Swift -
i have weird issue uicollectionview , uitabbarcontroller. inside uitabbarcontroller have references 2 different viewcontrollers. if put view controller has uicollectionview first page of uitabbarcontroller list cells (uicollectionview) loading this:
but if put second view controller when open tab uiimageview , uilabel disappearing cells:
i have checked collectionview method getting cells , there data printed label , image. here code of methods datasource , delagate
// tell collection view how many cells make func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { return self.items.count } // make cell each cell index path func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { // reference our storyboard cell let cell = collectionview.dequeuereusablecellwithreuseidentifier(reuseidentifier, forindexpath: indexpath) as! adscollectionviewcell // use outlet in our custom class reference uilabel in cell cell.mylabel.text = self.items[indexpath.item] cell.backgroundcolor = uicolor.whitecolor() // make cell more visible in our cell.layer.bordercolor = uicolor.graycolor().cgcolor cell.layer.borderwidth = 1 cell.layer.cornerradius = 8 cell.layoutifneeded() return cell } func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize { let width = collectionview.frame.width - 22; return cgsize(width: width/2, height: width/2); } // mark: - uicollectionviewdelegate protocol func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) { // handle tap events print("you selected cell #\(indexpath.item)!") }
is there had problem this? how can solved?
Comments
Post a Comment