4

I have an app which has a different UI for portrait and landscape. I've heard wonderful things about Auto Layout but in all my readings it seems to handle simple cases, where UI widgets resize and reposition simply. In my UI UI widgets move. Is this a case where I should try and get auto layout to work or should I just make 2 xibs and be done with it?

enter image description here

You can see in the portrait version that the green element is below the magenta one, but it is above it and next to the orange one in the landscape orientation.

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
  • 1
    I am not too sure, however if you make outlets to the constraints for each view and change its constant property accordingly to the desired settings you should be able manipulate it. Eg: if( IS_HEIGHT_GTE_568) { self.theWebViewHeight.constant = 403; } else { self.theWebViewHeight.constant = 315; } //For adjusting view for iPhone 5 and 4S – Urmil Setia Jul 02 '13 at 18:10

1 Answers1

6

Sorry, one auto layout setting will not allow you to rearrange views like that. You could still use auto-layout for positioning and spacing, but you'll need two sets of settings.

You could still use one xib file and change the auto layout settings at run time, but most likely multiple xibs makes more sense because you'll be able to see and edit your UI WYSIWYG style.

Update

Also, take a look at iOS 9's new UIStackView.

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143