Reputation: 2002
I've to develop an iPad app that should have a layout for portrait and a layout for landscape. This app should be able to work with iOS 8 and iOS 9. To design two different layout should I use 2 storyboards: one for the portrait layout and one for landscape layout or I can use only one storyboard with size classes?
I found this solution over stackoverflow, but I'm not sure if it's the right way to work with 2 different layout. Does anyone have an idea about how to work with a portrait layout and with a landscape layout with iPad? So you think it's better to use size classes or to use 2 different storyboard: one for landscape and one for portrait
Upvotes: 0
Views: 3607
Reputation: 2928
As per your question you need to use size class for creating application. But in traitCollection you will only get wRegular-hRegular for both landscape and portrait.
result of log value of trait collection with statusBarOrientation.
All you can do is add make constraints active and inactive in
-(void)updateViewConstraints {} method based on [UIApplication sharedApplication].statusBarOrientation.
First you need to bind the constraints you have given to the view and make their objects in .h or .m file.
Then you need to change the constant value of the constraint or make constraints active and inactive based on your requirement.
Result:
1.) iPad Portrait View
2.) iPad Landscape View
This is one way by which you can layout in iPad. Hope it helps you solving your problem.
Upvotes: 4