0

Possible Duplicate:
How to make app fully working correctly for autorotation in iOS 6?

having an issue with autorotation in iOS6. I have added this in App Delegate:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return (UIInterfaceOrientationMaskAll);
}

And added this in View Controller:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait);
}

I still cannot get it to just be portrait, and not landscape! Help is much appreciated.

Community
  • 1
  • 1
rjg
  • 105
  • 1
  • 12

2 Answers2

1

Paste this only to ViewController:

- (NSUInteger)supportedInterfaceOrientations
{
     return (UIInterfaceOrientationMaskPortrait);
}

Delete shouldAutorotate and application:supportedInterfaceOrientationsForWindow:.

Tomasz Szulc
  • 4,217
  • 4
  • 43
  • 79
  • Done this, hasn't worked. Do i select anything in the targets of the app settings, the Supported Interface Orientation Buttons? – rjg Jan 05 '13 at 16:38
  • Yes, you should select orientation which you want to have in your app. – Tomasz Szulc Jan 05 '13 at 19:52
1

You do not need to set the interface orientation in your App Delegate object. Select in the Project Navigator your Project File. Then select the Target and select Summery. Here you can select the Supported Interface Orientations. This works for the whole project.

Areal-17
  • 406
  • 3
  • 10
  • I need it to be different in different views. – rjg Jan 05 '13 at 16:58
  • @RyanGittings that's an anti-pattern and is discouraged in iOS 6. – Dave DeLong Jan 05 '13 at 16:59
  • Well, the majority of the app is data, and i have a view and loads an image, (FGallery), and i want to enable landscape to be able to view pictures landscape... – rjg Jan 05 '13 at 17:03
  • 1
    you do not net to return UIInterfaceOrientationMaskAll because it's the default value for iPad. The default for iPhone is UIInterfaceOrientationMaskAllButUpsideDown. Which device you're support? iPad or iPhone? – Areal-17 Jan 05 '13 at 17:13
  • Its an iPhone app... Removed from app delegate. What do i need to put in ViewController? I've unchecked all supported interface orientations in targets... – rjg Jan 05 '13 at 17:16
  • in the viewController object you want support automatic interface orientation overwrite the - (BOOL)shouldAutorotate and return yes. If you want specify orientation (for example: only landscapeLeft) overwrite the - (NSUInteger)supportedInterfaceOrientations method. (for example: - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft; } ) – Areal-17 Jan 05 '13 at 17:54
  • Still doesn't work, i dont know what im doing wrong. Added this to bottom of View Controller: `-(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }` and still no luck, still rotates in simulator. – rjg Jan 05 '13 at 19:12