0

I have 10 images with fixed dimensions (width, height). How do I choose the constraints in the Interface Builder when I want to let all images automatically float without any margin?

Like this, in Portrait mode the images would be aligned as

1 2 3
4 5 6
7 8 9
10

and in Landscape

1 2 3 4 5
6 7 8 9 10

In HTML with this effect would be automatic for the <img> tag, or when you have block elements as <div> you would apply float:left to all elements.

andreas
  • 7,844
  • 9
  • 51
  • 72

1 Answers1

1

You are describing the default behavior of a UICollectionView with a UICollectionViewFlowLayout, so maybe the simplest way is to use that, and let the flow layout lay out the image views for you.

If you don't want to do that, then you will simply have to perform layout yourself, supplying one set of constraints when the app orientation switches to portrait and a different set when the app orientation switches to landscape.

matt
  • 515,959
  • 87
  • 875
  • 1,141