1

Possible Duplicate:
Landscape Mode ONLY for iPhone or iPad

I'm working on a project to repurpose old iPhones as media hubs in cars. My particular need is obtaining some sort of tutorial or walk through specifically designating the steps needed to modify the default iOS screen orientation.

Many people have used the Landscape Rotation Lock in Cydia to disable Landscape mode, my goal is just the opposite.

I'd like to disable Portrait mode, as the end result will see the iPhone mounted in my car horizontally, thus requiring Landscape orientation only.

How can this be done?

Community
  • 1
  • 1
Dan Solo
  • 11
  • 2
  • 3
    Same as, http://stackoverflow.com/questions/5777313/xcode-how-to-build-a-landscape-only-iphone-programe – Devraj Jul 12 '12 at 03:54
  • You can easily "hardwire" your app to landscape-only. But I'm guessing there's no way to force the phone to display everything landscape. – Hot Licks Jul 12 '12 at 04:06

2 Answers2

0

Try this

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
Sanchit Paurush
  • 6,114
  • 17
  • 68
  • 107
  • Uh, he probably only wants one of those orientations, or else the image may appear upside-down. – Hot Licks Jul 12 '12 at 04:07
  • @HotLicks Then he may remove the Or part from the return statement. – Sanchit Paurush Jul 12 '12 at 04:10
  • Thanks for your input guys. If you check this link http://stackoverflow.com/questions/3176577/remove-ability-for-portrait-orientation-for-app-in-iphone-sdk it appears that the code is already there. I'm an xcode virgin, so I have no idea where to begin or how to get to the point where I modify this code. – Dan Solo Jul 12 '12 at 04:24
0

Use Supported interface orientations to Landscape (left home button) and set its value in your info.plist file. This will start your app in that orientation and you need to set

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

In every viewController.

Hope this is what you are looking for. Let me know if you need anything else.

Update

Hi @DanSolo I think you have your application created in XCode right? if so than goto your any view controller and check for the shouldAutorotateToInterfaceOrientation method. This method will be called when you rotate your device. If you will return Yes than it will get rotate otw it won't. In your case you will return

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

This will return Yes only in your landscape Left mode. If you want both landscape left and right use

return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
        (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

This code will go in your every viewController's shouldAutorotateToInterfaceOrientation method.

Hope it helps :)

Kapil Choubisa
  • 5,152
  • 9
  • 65
  • 100