1

i have an application build on xcode 4.2 , which supports only portrait orientation, it works fine with all devices except ios6 .. In Ios 6 devices it is showing both orientations .. I need only portrait orientation .. i am using navigation controller .. IN appdelegate::

- (BOOL)shouldAutorotate
{

      return ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait);
}


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

in other viewControllers ::

- (BOOL)shouldAutorotate {
    return YES;
}

- (void)viewDidLayoutSubviews
{
    DisplayFunctionName;
    NSLog(@"orientation: %d",self.interfaceOrientation);
}

- (NSUInteger)supportedInterfaceOrientations
{
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
    {
        return (UIInterfaceOrientationMaskAll);
    }
    else
    {
        return (UIInterfaceOrientationMaskPortrait);
    }
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    DisplayFunctionName;
    NSLog(@"orientation: %d",interfaceOrientation);
      return (interfaceOrientation==UIInterfaceOrientationPortrait);

}
Stefan
  • 5,203
  • 8
  • 27
  • 51
Rijo Payyappilly
  • 801
  • 8
  • 12
  • In other viewControllers, in `shouldAutoRotate` method, try replacing `return YES;` with `return ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait);`. – Geek Jun 22 '13 at 06:28
  • If you are only need the portrait orientation in your application it is better to disable all other orientations in your application plist configuration. – voromax Jun 22 '13 at 06:30
  • Did you solve the problem? – jamil Jun 22 '13 at 06:48

3 Answers3

2

In IOS6 handling of Orientation is difficult is case when you want portrait orientation for some views and for some you want landscape orientation, but its very easy if you want only one orientation support for entire app. simple go to Supporting Files and then open the info.plist in your app and remove all other orientation except one that you want.. below are few screen shot which help you to fix your issue

enter image description here

enter image description here

after removing all other orientation your info.plist will be looks like below enter image description here

i hope it works for you.Thanks

Community
  • 1
  • 1
jamil
  • 2,419
  • 3
  • 37
  • 64
1

iOS 6

shouldAutorotateToInterfaceOrientation: is deprecated and replaced by

shouldAutorotate

Check this : https://stackoverflow.com/a/14938444/305135

Community
  • 1
  • 1
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
0

Try using these ,

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationPortrait;
}
Venk
  • 5,949
  • 9
  • 41
  • 52