17

我目前的程序只支持横向。

在 iOS 6 中,它在UIPopoverController.

'UIApplicationInvalidInterfaceOrientation',原因:'支持的方向与应用程序没有共同方向,并且 shouldAutorotate 返回 YES'

我为项目启用了所有方向,它运行良好。但是,我需要对所有视图进行大量更改以仅支持横向。

UIOrientation还有其他简单的方法可以解决UIPopoverController吗?

4

5 回答 5

0

尝试将以下内容添加到您的UIApplicationDelegate

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

您仍然可以在文件中设置支持的界面方向,并在每个视图控制器的方法Info.plist中返回一个掩码。supportedInterfaceOrientations:

于 2012-09-21T05:37:52.333 回答
0
Use these delegates for orientation,
- (BOOL)shouldAutorotate
{

return YES;
}

-(NSUInteger)supportedInterfaceOrientations

{
return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}
于 2013-04-19T13:58:28.330 回答
0

你这个链接。您必须在开始时将您的应用程序设置为支持所有方向。在应用程序委托中进行更改。

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

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

}
于 2012-10-16T09:34:04.910 回答
0

新建 UIImagePickerController 的子类并添加以下代码:

@property (nonatomic)NSUInteger supportedInterfaceOrientations;

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

像这样使用它:

    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];
        }
    }

谁知道更好的方法请告诉我。

于 2012-09-24T03:49:24.880 回答
0
@interface NonRotatingUIImagePickerController : UIImagePickerController

@end

@implementation NonRotatingUIImagePickerController

- (BOOL)shouldAutorotate
{
    return NO;
}

@end

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

使用上面的代码,这对我有用。

于 2013-03-25T11:22:41.310 回答