3

I am just starting a new app and the request came to use Interface Builder this time (I normally do all my stuff programmatically) but anyway.

I am trying to have 2 Image Views sit next to each other on both Portrait and Landscape.

I was toying with the storyboard file and I came close but somehow I can't nail it down to work on Landscape.

It seems that my views are always bigger then the actual screen size and on landscape my views overlap each other.

Am I missing something with the auto-layout process?

Thank you in advance.

So here is a visual representation of what I am trying to do:

portrait landscape

Shuyinsama
  • 326
  • 6
  • 19
  • 1
    "Am I missing something with the auto-layout process?" Most likely, but how are we supposed to know if you don't tell us how you set up your constraints? – rdelmar Jul 25 '14 at 15:34
  • Oops sorry 'bout that. My problem is solved though but for general purpose. I started out by adding horizontal spaces to 1 view. then duplicate that view and give the both a equal height. After that I added some vertical space because of the change in height when rotating. After that it was all just a general mess... – Shuyinsama Jul 25 '14 at 19:09

1 Answers1

6

I have done a very similar task recently, here is my way:

1- Select your view controller in UI Builder

2- Editor->Resolve Auto Layout Issues->Clear All Constraints in View Controller

Now, we don't have any constraints on our View Controller.

3- Select both of the views(You can do it easier on Document Outline View)

4- Editor->Pin->Widths Equally

5- Repeat Step 3

6- Editor->Pin->Heights Equally

Xcode will complain about missing constraints at this point.

7- Repeat Step 1

8- Editor->Resolve Auto Layout Issues->Add Missing Constraints in View Controller

This should now work on all layout directions.

Timuçin
  • 4,653
  • 3
  • 25
  • 34