George
George

Reputation: 534

loading a different view on rotation

I am in the process of creating my first iPad application. I have an iPhone version and want to now make it better on iPad. It is a small game and the main playing screen consists of 24 images loaded on the screen.

In portrait, I want to show four columns, with six rows and in landscape I want six columns with four rows. From everything I have read and tried, I can't seem to find a way to do this. So, I was wondering if my best solution is to attempt to load a separate view for landscape and one for portrait?

I have heard about subviews but unfortunately there isn't much info on this and I'm not exactly sure what they even are. I love the bigger size with iPad and want to take advantage of it along with the rotation features.

Any help is greatly appreciated.

Geo...

Upvotes: 1

Views: 1560

Answers (1)

indragie
indragie

Reputation: 18122

UIViewController contains several hooks for making changes to your view hierarchy before and after a rotation. For example, you could use the willRotateToInterfaceOrientation:duration: to set the frame or make any changes necessary to your view to get the desired number of columns. That method and several others pertaining to rotation are detailed in the UIViewController documentation.

If you are not using UIViewController (for whatever reason), you could also register for the UIDeviceDidChangeOrientation notification. If the changes to the UI between portrait and landscape orientations are so drastically different that it wouldn't be feasible to adjust in code, you may want to create separate XIBs for each orientation and load the right one when the device changes orientation.

Upvotes: 1

Related Questions