2

I am working on an iPad application which is in both orientations having different layouts but we have only one size class for both orientations. How to make different layouts for landscape and portrait separately using size classes.

I have followed this answer but it does not make any difference.

Cœur
  • 32,421
  • 21
  • 173
  • 232

2 Answers2

0

I answered a similar question in detail here where I talk about activating and deactivating constraints so you can have a different layout on iPad for each orientation.

Community
  • 1
  • 1
Kurt Anderson
  • 922
  • 1
  • 10
  • 26
0

Change the view elements shown in your interface for different screen sizes and orientations. Installed views are added to the view hierarchy. Uninstalled views are not added.

So for your need you can do it like this,

Steps:

  1. Identify desired size class for your orientation then design your separate layout for separate size class using its installed and uninstalled property.
  2. If the utilities area is not open, choose View > Utilities > Show Utilities.
  3. Select the view you want to install or uninstall either on the canvas or from the outline view.

enter image description here

  1. In the Attributes inspector, click the Add button (+) next to the Installed property and choose the size desired class from the pop-up menu.

After choosing a size class from the pop-up menu, a new entry item for that size class appears in the Constraint inspector.

enter image description here

  1. Select the checkbox for the desired entry line to install the view for that size class. Deselect the checkbox to uninstall the view.

enter image description here

In above image, lighten view represents views which are designed but included in this particular version of size class.

You can find detailed explanation over this apple document on installing and uninstalling views for size classes.

Akshay Sunderwani
  • 12,084
  • 8
  • 26
  • 52
  • This is hide and unhide of a particular object I have used this but exactly what I want is different layouts using same objects in landscape and potrait just like iPhone as using different objects for different orientation is not a good approach it will increase the size of my project only. – Hemlata Khajanchi Sep 01 '15 at 06:00
  • Use constraints with object and play with them pro-grammatically in run-time to manage different layouts. @HemlataKhajanchi – Akshay Sunderwani Sep 01 '15 at 06:19