1

I have an app with a cuople of views with different view controllers. One is a map view and one a web view that I want to be available both in portrait/landscape. Before I just this code that in all my view controllers that locked all of them in portrait:

- (BOOL)shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

But when I updated to Xcode 4.5/IOS6 all of them suddenly could be flipped. So now I decided to keep the map view/web view flippable. But I have a menu that I want to be locked in portrait and I doesn't work with the code above nor with:

}

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

Any ideas?

Thanks on beforehand!

1 Answers1

0

You could just do it from the project settings in Project -> Targets -> Project Name -> Summary -> Supported Interface Orientations -> Portrait.

Alternatively, you could add the following to your appdelegate -

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;

}

And add the following to your viewcontroller -

- (NSUInteger)supportedInterfaceOrientations
{
//    UIInterfaceOrientationMaskLandscape;
//    24
//
//    UIInterfaceOrientationMaskLandscapeLeft;
//    16
//
//    UIInterfaceOrientationMaskLandscapeRight;
//    8
//
//    UIInterfaceOrientationMaskPortrait;
//    2

//    return UIInterfaceOrientationMaskPortrait;
//    or
return UIInterfaceOrientationMaskPortrait;
}

-(BOOL) shouldAutorotate
{
    return YES;
}
Arunabh Das
  • 13,212
  • 21
  • 86
  • 109
  • It gave me an error saying `Conflicting return type in implementation of 'application:supportedInterfaceOrientationsForWindow:': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned long')`. iOS 9 Xcode 7. – Bista Oct 21 '15 at 10:56