2

Hi i have following scenario :

1) ViewControllerA >> pushes ViewControllerB

2) In ViewControllerB I have 3 buttons as AUTO , LANDSCAPE, PORTRAIT.

3) If user clicks on AUTO button the particular view controller should always be visible in PORTRAIT + LANDSCAPE mode depending on the orientation mode

4) If user clicks on LANDSCAPE button the particular view controller should always be visible in LANDSCAPE mode irrespective of the orientation of device.

5) If user clicks on PORTRAIT the particular view controller should always be visible in PORTRAIT mode irrespective of the orientation of device.

Forcing orientation on a particular view controller

I am working on iOS 7.0 both for iPad and iPhone.

Tried many links on Stack Overflow but all give suggestions for 6.0 and those doesn't work out in 7.0

Can anybody suggest me how to achieve this..

Swati
  • 2,870
  • 7
  • 45
  • 87

2 Answers2

1

This is working but not perfectly :

force landscape ios 7

Still need to check if its a private API as that may cause issue..

hey RAJA i have already tried this link before : Force Landscape Orientation on iOS 6 in Objective-C

but this was not perfect either.... [will definitely try to change some code may be it can work]

Community
  • 1
  • 1
Swati
  • 2,870
  • 7
  • 45
  • 87
1

Try this..

Create property orientationStyle as nsinteger in Appdelegate and change the value of orientationStyle from the ViewControllerB according to the button click.

Add the below method in Appdelegate.

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
switch (orientationStyle) {
    case 0:
        return UIInterfaceOrientationMaskPortrait;
        break;
    case 1:
        return UIInterfaceOrientationMaskLandscape;
        break;
    case 2:
        return UIInterfaceOrientationMaskAll;
        break;

    default:
        return UIInterfaceOrientationMaskAll;
        break;
}
}

Hope it will help you

RAJA
  • 1,214
  • 10
  • 13
  • then try this. http://stackoverflow.com/questions/13872244/force-landscape-orientation-on-ios-6-in-objective-c – RAJA Mar 06 '14 at 10:22