Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Makeing an image grid in Xcode

I want to make a 8x10 grid of images. I need to turn each image on and off independently, and they need to keep a 1:1 ratio but grow and shrink so they fit on the screen. At first I tried inserting 80 different image views, that I would add to a struct so they could be represented by coordinate to be hidden and un-hidden. But this really didn't work out because it got so complicated. Now i am trying to use a collection view, that I set to a 8:10 aspect ratio and 80 containers. I added some UIImageViews to the containers and they never showed up on the simulation.

Is there a better way I could be going about this? is the collection view the right path? if so how do I format, add the images and access coordinates to turn them on and off?

Thanks in advance!

1 Answer

Hi Mark,

Sounds to me like a uicollectionview is exactly what you need. I would google around for some basic tutorials on them, and maybe check out this WWDC session video for some more advanced things you can do with them:

https://developer.apple.com/videos/play/wwdc2014-232/