سؤال

I've been researching this issue for a couple days now and I don't have a clear answer.

The answer posted at the following link is close and describes using two story boards: 2 storyboards for portrait and landscape

Another solution is to create another view within the same view controller and hide/unhide.

The problems with these solutions is that in the former, data needs to be copied to the new controller and could cause state problems. In the latter solution if I use two views I need to then create duplicate IBOutlets for every member in the view!

I wish I could simply do the following:

  1. Create a storyboard which contains a portrait and a landscape view.
  2. Set a single outlet for each property that each view can reference.
  3. Rotate the view as needed.

I hope to solve this issue before I go down the wrong rabbit hole.

NOTE: Storyboard does not allow movement of UIViews outside of the hierarchy for design purposes. I can do this in .xib files. This means if I have a portrait and landscape view in a .xib I can physical move them to separate areas to edit them. Storyboards do not allow this so I would have to create a separate view controller in landscape mode, edit it, then move the view into place. However, it would be a pain to make edits in the future.

Any help is appreciated.

هل كانت مفيدة؟

المحلول

I've found the best way to handle landscape is handling it in code. Why use an additional storyboard to move or hide UI elements? That seems way less maintainable. Also, handling the rotation in the same view controller will show the UI animations as the elements are moved.

Hope that helps you in the right direction.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top