LiangWang
LiangWang

Reputation: 8816

Universal project: how to make landscape start-up in iPhone and portrait in iPad

I have an universal project, and want to keep landscape from very beginning of star-up for iPhone and portrait for Pad. How can I do it?

Upvotes: 2

Views: 406

Answers (2)

coder
coder

Reputation: 5390

If the device is already in landscape position it will start as landscape, but if you want your program to work always in landscape position and never flip to portrait, you have to set the orientation to landscape in each class you create:

     - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

return (interfaceOrientation == UIInterfaceOrientationLandscape || interfaceOrientation ==       UIInterfaceOrientationPortraitUpsideDown);
    }

Upvotes: 0

Cocoanetics
Cocoanetics

Reputation: 8247

That's not possible. iPhone apps always have to start in Portrait orientation. Any game you see that has landscape-only display is still starting showing a portrait default image and the root view controller then can be landscape-only.

On iPad you can restrict the app orientation to Landscape and also have it start in Landscape.

The iPhone restriction is enforced by Apple and they won't approve an iPhone app that restricts itself to Landscape start.

Upvotes: 0

Related Questions