iOS中的UIPopoverController方向崩溃6
我当前的程序只支持横向方向。iOS中的UIPopoverController方向崩溃6
在iOS 6中,它崩溃在UIPopoverController
。
“UIApplicationInvalidInterfaceOrientation”,理由是:“支持 方向与应用程序中没有共同的方向,并 shouldAutorotate将返回YES”
我能为项目的所有方向,它的工作好。但是,我需要对所有视图进行大量修改才能支持风景。
有没有其他简单的方法来修复,UIOrientation
在UIPopoverController
?
尝试添加以下到您的UIApplicationDelegate
:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
您还可以设置你支持的接口方向在Info.plist
文件,并通过返回在每个视图控制器的supportedInterfaceOrientations:
方法的面具。
这是正确的,按照https://devforums.apple.com/message/731764#731764 – Zeophlite 2012-10-02 17:33:44
新的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-28 12:12:31
这不是一个setter方法 imagePickerController.supportedInterfaceOrientations = UIInterfaceOrientationMaskLandscapeRight; 完全错误... – 2012-12-28 07:58:56
您的这个link。您必须将您的应用程序设置为在开始时支持所有方向。在应用程序委托中进行更改。
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return UIInterfaceOrientationMaskAll;
else /* iphone */
return UIInterfaceOrientationMaskAllButUpsideDown;
}
@interface NonRotatingUIImagePickerController : UIImagePickerController
@end
@implementation NonRotatingUIImagePickerController
- (BOOL)shouldAutorotate
{
return NO;
}
@end
UIImagePickerController *picker = [[NonRotatingUIImagePickerController alloc] init];
使用上面的代码,这为我工作。
Use these delegates for orientation,
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
嗨@satungod,我的答案不幸被管理员删除,因为我已经将它发布到另一个线程......足够公平。请在这里找到这个答案:http://stackoverflow.com/a/12575058/662605 - 我添加了一个新的答案,直接指向另一个。 – Daniel 2012-09-25 13:53:13