4

I have an issue that, I have two different UI designs for iPad portrait and landscape orientations. But, in size classes Regular|Regular meant for ipad portrait and landscape too.

  1. Is it possible to design two different layouts for ipad devices?
  2. How can we design two different layouts for ipad devices.
Bhanu Prakash
  • 1,493
  • 8
  • 20

2 Answers2

1

It is not possible to differentiate orientations of iPad using size classes alone. The approach I used is to create 2 different layouts in the storyboard and switch between the two programatically on device rotation. It's not the perfect solution but it might be the closest one.

schystz
  • 800
  • 1
  • 8
  • 21
0

First design you UI in wAny|hAny size class.

Now make the necessary changes to layouts in wRegular|hAny size class for iPad landscape and wAny|hRegular size class for iPad Portrait.

If that does not work out, we need to make the different layouts with code as follows.

if traitCollection.verticalSizeClass == .Regular && traitCollection.horizontalSizeClass == .Regular {

     var orientation:UIInterfaceOrientation = UIApplication.sharedApplication().statusBarOrientation;
     if orientation == UIInterfaceOrientation.LandscapeLeft || orientation == UIInterfaceOrientation.LandscapeRight {
            // orientation is landscape


     }  else {
            // orientation is portrait

     }
}

Hope this helps. :)

i 4322946
  • 173
  • 2
  • 9