UIPopoverController orientation crash in iOS 6 [du

2019-03-17 22:29发布

This question already has an answer here:

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 ?

5条回答
劳资没心,怎么记你
2楼-- · 2019-03-17 22:31

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.

查看更多
太酷不给撩
3楼-- · 2019-03-17 22:35
Use these delegates for orientation,
- (BOOL)shouldAutorotate
{

return YES;
}

-(NSUInteger)supportedInterfaceOrientations

{
return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}
查看更多
▲ chillily
4楼-- · 2019-03-17 22:37
@interface NonRotatingUIImagePickerController : UIImagePickerController

@end

@implementation NonRotatingUIImagePickerController

- (BOOL)shouldAutorotate
{
    return NO;
}

@end

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

Use Above Code, this worked for me.

查看更多
再贱就再见
5楼-- · 2019-03-17 22:50

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.

查看更多
孤傲高冷的网名
6楼-- · 2019-03-17 22:52

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;

}
查看更多
登录 后发表回答