我在视图控制器中呈现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中的所有方向
任何人都可以帮我解决这个崩溃问题。