I'm working on an app in Swift using XCode 6 and iOS 8. This app contains a collection view that I'd like to load an array of images into.
When I'm using just one image I can repeat it as many times as I'd like, but when iterating through the array only the last image is repeated vs the unique images appearing in the collection view.
My array is defined as this inside my class:
var listOfImages: [UIImage] = [
UIImage(named: "4x4200.png")!,
UIImage(named: "alligator200.png")!,
UIImage(named: "artificialfly200.png")!,
UIImage(named: "baitcasting200.png")!,
UIImage(named: "bassboat200.png")!,
UIImage(named: "bighornsheep200.png")!,
UIImage(named: "bison200.png")!,
UIImage(named: "blackbear200.png")!,
UIImage(named: "browntrout200.png")!
]
Next I have the following to iterate through the array and display the images:
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CollectionViewCell
// Configure the cell
for images in listOfImages{
cell.imageView.image = images
}
return cell
}
This compiles and displays but is only displaying browntrout200.png. What am I missing to display all the images?