2016-03-22 8 views
1

以下のシナリオでは、セルの背景(黒色)を表示することはできません。コレクションビューで表示されていないセルがストーリーボードから埋め込まれています

ストーリーボードでは、イメージビューをコンセントとして持つカスタムUICollectionViewCellを持つ埋め込みカスタムUICollectionViewを持つコンテナがあります。別のView Controllerでは、同じコレクションビューとセルが必要な場所にコンテナを挿入しました。

storyboard

私は(両方の印刷がコンソールとnilを返さない)カスタム・コレクション・ビューとセルをインスタンス化することができるように見えます。次のコードは、以下のように表示されます。 collectionView

細胞画像オプション({320、213})

オプション((78.0、78.0))

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell 
{ 
    print("into the collectionView") 
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("photoCell" , forIndexPath: indexPath) as! PhotoCollectionViewCell 

    cell.backgroundColor = UIColor.blackColor() 
    let myRect = CGRect(x: 0, y: 0, width: 78, height: 78) 
    cell.frame = myRect 

    cell.autoresizesSubviews = false 

    if let imageForCell = images?[indexPath.row] 
    { 
     cell.cellImageView.image = imageForCell 
     print("cell image \(cell.cellImageView.image)") 
    } 
    print(cell.cellImageView?.bounds.size) 
    cell.cellImageView?.layer.borderWidth = 1.0 
    cell.cellImageView?.layer.borderColor = UIColor.blackColor().CGColor 

    return cell 
} 

私はすべての提案された解決策を試みたが、コレクションビュー内でセルを表示することはできません。

答えて

1

両方のコンテナを持つコントローラを組み込みます。コントローラーで何をしても、両方のコンテナに反映されます。

storyBoard

関連する問題