0

really new to iPad development here. I made some mockups for what I'm trying to do.

enter image description here

I have a layout like so with options and menu at the bottom. When I rotate to landscape I want to get something like this:

enter image description here

In landscape the menu bar will always be on the right. In portrait always at the bottom. The contents of the square keep their position and rotation regardless of the device orientation.

What would be the rest way of going about this? I have considered removing all the views as the device begins to rotate and then replacing them using new coordinates. Doesn't seem like the animation will be smooth though. I understand how to do constraints, but I want the top square to stick to the tom when portrait and stick to the left when landscape, not always at the top. Any pointers on this would be really appreciated! thank you

KexAri
  • 3,867
  • 6
  • 40
  • 80

1 Answers1

0

This is a job for size classes. They let you define separate layouts for different orientations and would be an ideal solution for your problem. However, for some reason, the difference between iPad portrait and landscape orientation is not directly supported by the the current implementation of size classes.

There is a workaround, Sizing class for iPad portrait and Landscape Modes, that can redefine the meaning of the existing size classes to fit your problem. In other words, you can use the portrait and landscape size classes for the iPhone and re-map them so that they apply to the iPad.

They are selected by a 3x3 grid in Xcode’s Interface Builder. If you play with it a little, it’s easy to grasp the concept.

Here is a screen capture of the control in Interface Builder that lets you switch among your different layouts:

enter image description here

Daniel Zhang
  • 5,778
  • 2
  • 23
  • 28
  • You would think, except for some reason Apple hasn't made it possible to determine whether an iPad is in portrait or landscape using size classes. – Paulw11 Oct 20 '15 at 21:45
  • I see, @Paulw11, that all the iPad size classes do not distinguish between portrait and landscape. I wonder what the reason is behind that. – Daniel Zhang Oct 20 '15 at 21:48
  • Don't know. There is a good work-around here -http://stackoverflow.com/questions/26633172/sizing-class-for-ipad-portrait-and-landscape-modes/28268200#28268200 – Paulw11 Oct 20 '15 at 21:52
  • Thanks. I've added it to my answer. – Daniel Zhang Oct 20 '15 at 22:15