0

I am developing an iPhone application in which i have to change the oreintation to landscapeleft and landscaperight.Its working in iPhone 4 but not in iPhone 5.Please let me know how to do for ios 6.The piece of code i am using is below.

Thanks.

user1746965
  • 1
  • 1
  • 4

3 Answers3

0

Add this code

-(NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);
}

It worked for me Hope it helps you!

EDIT

Also add this code

- (BOOL)shouldAutorotate
{
    return YES;
}
P.J
  • 6,547
  • 9
  • 44
  • 74
  • If you are using presentViewController, refer this link : http://stackoverflow.com/questions/12566780/presentviewcontroller-not-supporting-orientation-in-ios-6 – P.J Nov 05 '12 at 11:39
  • Thanks,I used your code but it didnt work,Is there any other places i have to make changes. – user1746965 Nov 05 '12 at 11:57
  • try adding code which I have added in EDIT section in my answer – P.J Nov 05 '12 at 12:01
  • Thanks but i added the code you gave me but still its not working.The code i added is -(NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight); } - (BOOL)shouldAutorotate { return YES; } Is there any other way to do this. – user1746965 Nov 05 '12 at 12:10
  • is you application using presentViewController or presentModalViewController? – P.J Nov 05 '12 at 12:24
  • then refer this link http://stackoverflow.com/questions/12566780/presentviewcontroller-not-supporting-orientation-in-ios-6 – P.J Nov 05 '12 at 12:48
  • A few other places you may want to check for problems:(1) Ensure that your window's rootViewController is set. (2) Depending on which view controller class is set, append your rotation changes there. (3) Remove all Supported interface orientations under applicationName-Info.plist. I find that the settings here may override the ones you will make in the codes. – ushika Nov 15 '12 at 00:25
0

It doesn't work as nicely as it was in IOS6, I had the same issue.Since they introduced new rotation, but the old way of running navigation controller(because my app needed to support 4.3 as well) does make it very hard.

Read my question and solution should be able to help you:

my ansswer

Community
  • 1
  • 1
phil88530
  • 1,499
  • 3
  • 19
  • 27
0

Try this

-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{

    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

-(BOOL)shouldAutorotate
{

    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationMaskLandscapeRight;
}