简体   繁体   English

在iOS6中呈现UIImagePickerController时,应用程序崩溃

[英]App getting crash while presenting UIImagePickerController in iOS6

I am presenting UIImagePickerController from the view controller. 我从视图控制器呈现UIImagePickerController Its getting the following crash report only in iOS 6 but not getting in iOS 7. 它仅在iOS 6中获得以下崩溃报告,而在iOS 7中则没有。

*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'

I am getting this crash only when presenting the UIImagePickerController . 我只有在呈现UIImagePickerController时才遇到此崩溃。

My app supports Portrait orientation so i am using the following code 我的应用程序支持纵向方向,因此我正在使用以下代码

-(BOOL)shouldAutorotate {

    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    if(UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
        return YES;

    return NO;
}

-(NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

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

    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    return self.interfaceOrientation;
}

But only one page will support both portrait and landscape orientation so i enabled all orientations in info.plist 但是只有一页将同时支持纵向和横向方向,因此我在info.plist中启用了所有方向

在此处输入图片说明

can any one pls help me that how to fix this crash. 谁能帮助我解决此崩溃的问题。

You can check this Stack overflow question This may help you. 您可以检查此堆栈溢出问题,这可能会对您有所帮助。 i had same same issue in a previous project and this helped out me. 我在以前的项目中遇到过同样的问题,这对我有所帮助。 try it 试试吧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM