Matching game without UICollectionView or scrolling

Working on a basic Matching game based on the excellent course I’m going through. I would like to do a similar app with a unique twist, but want to display all the available cards at the same time without scrolling.

Doesn’t make sense to use a subclass of UIScrollView when I’m not scrolling. From a design perspective, would it make more sense to just create the same number of views as cards and then lay them out and use autoconstraints to have them fill in based on the screen size?

As a follow-up, can I have a different number of cards with an iPad screen? Would I use storyboards or code to set that all up (different number of cards based on screen size)?

Still pretty new to development so any insights would be appreciated.

Seems like it would be small cards on the small iPhone, unless you are only going to have a few cards, I suppose.

You can get the device the user is using ( and create different storyboards based on the device. And then uses a collectionView to fill with the numbers of card you want the user to play.

This is how I might tackle the idea.

Good luck.

Does the collectionview have to scroll? I guess as long as the cards all fit on the screen, I wouldn’t have to worry about scrolling and dequeueReusableCell? Just use the collectionview as a way to keep track of the cells and their indexPath.row? Could I just use an array of a custom UIView class on the screen and maybe re-size that as needed to fit different screen sizes?

Thanks for responding and your input!!

Since you want all the cards to stay visible, nope, you would not need to add a scroll view. But come to think of it, I think you will need to add one, but that does not mean it needs to scroll. Will have to tinker with that.

Let us know how your project is coming along.

it would be hard to track dynamically generated uiviews yet alone set up separate functions for them, like for example the card flipping as they can’t “share” the same code/function you use

best way is to just still do it with collection view and make the sizes (of the cards) change depending on the screen size and hope it all fits without needing for the scroll to appear :thinking:

I’ve done a tutorial where you just used an array of buttons to act as cards. Picking a button returned a index into the array that was then used to select a card from the model. The array of buttons would then just update from the model each time something was selected. I was thinking I could do an array of custom UIViews so I could get more functionality such as animations. Working on it now.