2

Our app only supports Landscape mode and need to support iOS5.1 & 6.0 & 7.0. Bynow, we've set the rootviewcontroller and BaseSdk : 7.0 DeploymentTarget : 5.1

Our App is working fine in iOS 5 and ios 6. But in iOS7, when the alertview is present and the user rotating to portrait, alertview also rotating to potrait, which not happens on iOS5 & 6. And also once alertview went to portrait, it doesn't rotate to landscape.

Note: My ViewController's orientation is fine. It is always only supports Landscape.

ashoksl
  • 383
  • 6
  • 17
  • 1
    Where are you calling your alert view? Can we see some code? – Robert Nov 26 '13 at 15:54
  • @Robert - (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation { if (landScapeOnlyView) { return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } else if (openView) { return YES; } return NO; } This is the code that i'm using for orientation. – ashoksl Nov 27 '13 at 15:28
  • I had a similar but almost opposite problem - AlertView rotating when it shouldn't. Question and solution (move calling of AlertView method to `ViewDidAppear`) are here: http://stackoverflow.com/questions/19833129/prevent-alertview-from-auto-rotating – Robert Nov 27 '13 at 15:34
  • @Robert I Solved the issue by implementing the -(NSUInteger)supportedInterfaceOrientations method. when the alertView appears, supportedInterfaceOrientations method is called, where as for other views - (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOri‌​entation called. That's making the problem for me. – ashoksl Nov 28 '13 at 04:52

2 Answers2

2

I Solved the issue by implementing the supportedInterfaceOrientations Method: Before i've used only

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if (landscapeOnly) {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    else {
        return YES;
    }
}

Now i've implemented supportedInterfaceOrientations method also along with that. Because when alert view comes, supportedInterfaceOrientations is called automatically.

-(NSUInteger)supportedInterfaceOrientations{
    if (landscapeOnly) {
        return ((1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight));
    }
    else{
        return ((1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown));
    }
}

( 1 << UIInterfaceOrientationLandscapeLeft) is for UIInterfaceOrientationMaskLandscape

ashoksl
  • 383
  • 6
  • 17
0

Here is some links that can help you:

iOS 7 Viewcontroller not rotating when alertview is present

iOS 7: UIAlertView created in UIActionSheet delegate function cannot auto rotate

Hope this is helps you.

Community
  • 1
  • 1
theShay
  • 247
  • 5
  • 20