UIPopoverController orientation crash in iOS 6 [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-03 16:49:57

问题


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 ?


回答1:


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.




回答2:


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.




回答3:


@interface NonRotatingUIImagePickerController : UIImagePickerController

@end

@implementation NonRotatingUIImagePickerController

- (BOOL)shouldAutorotate
{
    return NO;
}

@end

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

Use Above Code, this worked for me.




回答4:


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;

}



回答5:


Use these delegates for orientation,
- (BOOL)shouldAutorotate
{

return YES;
}

-(NSUInteger)supportedInterfaceOrientations

{
return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}


来源:https://stackoverflow.com/questions/11928885/uipopovercontroller-orientation-crash-in-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!