Yes, I noticed that.
The issue you are having is identical to that which Jimmy had. Something has happened to the CollectionView that I just cannot figure out.
The only solution was to delete the collectionView and add it back in again and then connect up the elements (collectionView in ViewController and the imageViews in CardCollectionViewCell).
Works fine now.
I would recommend that you re-create the collectionView in your version. Good practise for you.
So to correct your version you need to:
- Delete the collectionView from storyboard.
- Add a new one in from the object Library. make sure that you select
- Constrain it to the safeArea of the View - 0 on all for sides.
- Set the background of the CollectionView to
- Assign a
reuse identifier to the Collection View Cell
- Set the size of the Cell to 158 x 224
- Assign the Custom class
CardCollectionViewCell to the Collection View Cell
- Add the two image views into the ContentView of the cell
- Assign an image to the front and back
- Constrain each to the ContentView - 0 on all sides
- Add outlets for the collectionView and each of the imageViews (frontImageView and backImageView)
- Set Xcode into Assistant Editor Mode. Simplest way is to hold the Option key and click on ViewContoller or CardCollectionViewCell and re-establish the Outlets.
Given that you already have the code in place for the IBOutlets in both ViewController and CardCollectionViewCell you can very quickly reconnect them by clicking on the circle at the line number and drag that across to the entry in the Document Outline.
As an example if you have ViewController visible in Assistant Editor Mode then where you have the line
@IBOutlet weak var collectionView: UICollectionView! you will see the circle on the left where the line number is. Click on it and drag that (a blue line will show as you drag it) to Collection View in the Document Outline and let go as you hover over the name Collection View. That will re-connect the link. Do the same for the frontImageView and backImageView in CardCollectionViewCell.
A point to note when you name things. There is a naming convention for constants, variables and functions (methods). They should alway be defined with the first letter of the name as lower case and any subsequent word in the name should have the first letter in Uppercase. When you name a class or a reuse Identifier the normal accepted naming method is for all words to have the first letter Upper Case. So the reuse identifier for card cell should be CardCell.
Hope that helps.