UICollectionViewCell不显示imageView。我使用情节提要在UICollectionView的顶部添加了ImageView
我正在使用故事板创建Collectionview。我在UICollectionViewCell的顶部添加了ImageView。但我看不到任何图像 下面是我下面的教程链接。 请指导我,我是ios编程新手 下面是我的代码UICollectionViewCell不显示imageView。我使用情节提要在UICollectionView的顶部添加了ImageView,uicollectionview,swift2,uicollectionviewcell,uicollectionviewlayout,Uicollectionview,Swift2,Uicollectionviewcell,Uicollectionviewlayout,我正在使用故事板创建Collectionview。我在UICollectionViewCell的顶部添加了ImageView。但我看不到任何图像 下面是我下面的教程链接。 请指导我,我是ios编程新手 下面是我的代码 //MyCollectionViewCell 类MyCollectionViewCell:UICollectionViewCell{ @IBOutlet weak var imageView: UIImageView! } 类MyCollectionViewControlle
//MyCollectionViewCell
类MyCollectionViewCell:UICollectionViewCell{
@IBOutlet weak var imageView: UIImageView!
}
类MyCollectionViewController:UICollectionViewController
{
var myArray:NSMutableArray=[]
override func viewDidLoad() {
myArray = ["a.jpg", "b.jpg"]
}
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return myArray.count
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let myCell: MyCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("MyCell", forIndexPath: indexPath) as! MyCollectionViewCell
print(myArray[indexPath.row] as! String) //Prints a.jpg b.jpg
myCell.imageView.image = UIImage(named: myArray.objectAtIndex(indexPath.row) as! String)
return myCell
}
我已经确保数据源和委托设置正确。是否连接了imageView插座?是,我连接了imageView插座。