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

时间:2014-07-30 05:04:13

标签: ios objective-c iphone uiimagepickercontroller uiinterfaceorientation

我在视图控制器中呈现UIImagePickerController。它仅在iOS 6中获得以下崩溃报告,但未在iOS 7中获得。

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

我只是在展示UIImagePickerController时才会崩溃。

我的应用支持纵向方向,因此我使用以下代码

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

但只有一个页面支持纵向和横向,所以我启用了info.plist中的所有方向

enter image description here

任何人都可以帮我解决这个崩溃问题。

1 个答案:

答案 0 :(得分:1)

您可以查看Stack overflow question这可能会对您有所帮助。我在以前的项目中遇到了同样的问题,这对我有所帮助。试试吧