【发布时间】:2015-08-14 06:39:17
【问题描述】:
我的 imageViews 仍然不显示图像,如果有人能指出问题所在,将不胜感激。
这里是集合视图函数:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell : UICollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("CELL ID", forIndexPath: indexPath) as! UICollectionViewCell
let imageView = UIImageView(frame: cell.contentView.bounds)
imageView.image = UIImage(named: "gear.png")
cell.contentView.addSubview(imageView)
return cell
}
在 viewDidLoad 我有:
collectionView.delegate = self
collectionView.dataSource = self
collectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "CELL ID")
使用正确的 CELL ID 标识单元格,并且我知道该部分正在工作,因为我可以设置这些单元格的背景颜色并且它会显示出来。 imageView 显示为黑色。我可以在设置imageView的同时设置背景颜色,颜色会显示出来。
【问题讨论】:
-
检查是否有名为 gear.png 的图片,甚至检查扩展名
标签: ios swift uiimageview uicollectionview uicollectionviewcell