我目前的程序只支持横向。
在iOS 6中,它在UIPopoverController
上崩溃。
'UIApplicationInvalidInterfaceOrientation',原因:‘支持的方向与应用程序没有共同的方向,shouldAutorotate返回YES’
我为项目启用了所有方向,它工作得很好。但是,我需要对所有视图进行大量更改,以仅支持横向视图。
有没有其他简单的方法来修复UIPopoverController
中的UIOrientation
?
发布于 2012-09-21 13:37:52
尝试将以下内容添加到UIApplicationDelegate
中
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
您仍然可以在Info.plist
文件中设置受支持的接口方向,并在每个视图控制器的supportedInterfaceOrientations:
方法中返回一个掩码。
发布于 2012-09-24 11:49:25
新建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-10-16 17:34:05
这就是link。您必须将应用程序设置为在开始时支持所有方向。在应用程序委派中进行更改。
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return UIInterfaceOrientationMaskAll;
else /* iphone */
return UIInterfaceOrientationMaskAllButUpsideDown;
}
https://stackoverflow.com/questions/11928885
复制相似问题