问题
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?
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.
回答1:
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.
来源:https://stackoverflow.com/questions/17432321/can-ioss-auto-layout-rearrange-ui-widgets