Deepak Sharma
Deepak Sharma

Reputation: 6581

UIStackView rotation

I have a UIStackView that holds 3 UIButtons, A, B, and C, horizontally in that order. The UIStackView is added to a subview of UIViewController's view when device is in Landscape mode. But when the device rotates to portrait mode, I want:

  1. UIStackView to display buttons vertically in the order B, C, A.
  2. UIStackView becomes subview of the main UIView of UIViewController as opposed to another subview of controller's view.

Is there an easy way to achieve it in Storyboard without programming or I need to change the autolayout constraints programmatically every time device auto-rotates?

Upvotes: 0

Views: 1128

Answers (1)

matt
matt

Reputation: 535945

I didn't have much trouble doing a simulation of (1) in Interface Builder alone in Xcode 9 beta:

enter image description here

But it's just a simulation — your spec seems to require that we change the order of the arranged subviews, and that obviously requires programming — and none of your spec would be possible without programming in Xcode 8 and before. (And I didn't understand the meaning of (2) so I didn't attempt it.)

But why be afraid of a little programming? Changing things programmatically at rotation time is part of life; you should get used to it.

Upvotes: 2

Related Questions