I have an app that requires me to have image views and labels to laid out differently depending on portrait or landscape orientation.
For example, in portrait mode, I have 2 UIImageViews on top and bottom that share the screen evenly. In landscape mode, the 2 UIImageViews are side by side. How can this be done using storyboard in Xcode 6?
Things I have tried:
- Settings constraints on the views in storyboard with size classes. I
set the base values for my 2 imageviews in
w:Any h:Any
, then moved tow:Compact h:Regular
and set constraints for portrait view.Then I moved tow:Any h:Compact
, moved the 2 imageviews side by side and set constraints for landscape view. Then I get conflicts inw:Compact h:Compact
because of the constraints I have applied for and landscape and portrait orientation. I think it's because I moved the image views around for landscape orientation before settings the constraints that caused this problem. - Using 2 separate view controllers and have portrait view controller switch to landscape view controller when orientation changes using NSNotificationCenter and performSegueWithIdentifier to push the landscape view controller on top of my portrait view controller. This problem is that there's lots of data to be passed(lot of imageviews and labels).
Is the a way to use only one view controller and a way to rearrange the imageviews/labels and apply new constraints on them when the orientation changes? Is -(void)viewDidLayoutSubviews{}
where I put the code to rearrange the image views? Can someone point me in the right directions? Thanks!