17

My current program only support landscape orientation.

In iOS 6, it crash on UIPopoverController.

'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

I enable all orientation for project , it's working well. However, I need to change a lot for all of the views to only support landscape.

Is there other easy way to fix , UIOrientation in UIPopoverController ?

Daniel
  • 23,129
  • 12
  • 109
  • 154
saturngod
  • 24,649
  • 17
  • 62
  • 87
  • 2
    Hi @satungod, my answer was unfortunately delete by a moderator because I had already posted it on another thread... fair enough. Please find this answer here: http://stackoverflow.com/a/12575058/662605 - I'm adding a new answer to direct to the other one. – Daniel Sep 25 '12 at 13:53

5 Answers5

0

Try adding the following to your UIApplicationDelegate:

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

You can still set your supported interface orientations in your Info.plist file and by returning a mask in each view controller's supportedInterfaceOrientations: method.

conmulligan
  • 7,038
  • 6
  • 33
  • 44
0

New a subclass of UIImagePickerController and add this codes:

@property (nonatomic)NSUInteger supportedInterfaceOrientations;

-(NSUInteger)supportedInterfaceOrientations{
    return _supportedInterfaceOrientations;
}
-(BOOL)shouldAutorotate{
    return YES;
}

Use it like this:

    if (imagePickerController==nil) {
        imagePickerController = [[WUIImagePickerController alloc]init];//the subclass
        imagePickerController.delegate = self;
        imagePickerController.supportedInterfaceOrientations = UIInterfaceOrientationMaskLandscapeRight;//any orientation you want to set
        if (popoverController==nil) {
            popoverController = [[UIPopoverController alloc]initWithContentViewController:imagePickerController];
        }
    }

Who knows a better way please tell me.

j0k
  • 22,600
  • 28
  • 79
  • 90
wayne
  • 9
  • 1
0

Thy this link. You have to set your application to support all orientations at the start. Do the change in app delegate.

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;
    else  /* iphone */
        return UIInterfaceOrientationMaskAllButUpsideDown;

}
Community
  • 1
  • 1
NiKKi
  • 3,296
  • 3
  • 29
  • 39
0
@interface NonRotatingUIImagePickerController : UIImagePickerController

@end

@implementation NonRotatingUIImagePickerController

- (BOOL)shouldAutorotate
{
    return NO;
}

@end

UIImagePickerController *picker = [[NonRotatingUIImagePickerController alloc] init];

Use Above Code, this worked for me.

iTejas
  • 41
  • 3
0
Use these delegates for orientation,
- (BOOL)shouldAutorotate
{

return YES;
}

-(NSUInteger)supportedInterfaceOrientations

{
return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}
karthika
  • 4,085
  • 3
  • 21
  • 23