我有一个仅在某些部分(照片库、视频等)支持横向方向的应用程序,并且在 iOS 6 上一切正常,没有问题,但是在 iOS 7 中应用程序崩溃。
所以这是我的问题:
- 启动应用程序并使用仅支持纵向的视图控制器加载初始导航控制器
- 将视图控制器推送到支持横向和纵向的堆栈
- 将视图旋转到横向
- 弹出视图控制器
- 应用程序崩溃
--> CRASH: **preferredInterfaceOrientationForPresentation must return a supported interface orientation!** 2013-11-06 10:18:06.220 ausopen-iphone-2014[57605:70b] Stack Trace: ( 0 CoreFoundation 0x03f665e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x03ce38b6 objc_exception_throw + 44 2 CoreFoundation 0x03f663bb +[NSException raise:format:] + 139 3 UIKit 0x01366f1c -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:]
+ 580
其他信息:
在我的 info.plist 中,我支持纵向和横向
在我的 AppDelegate 中,我实现了以下方法:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{}
在这个方法中,我指定如果第一个视图 (HomeVC) 显示它应该支持所有方向。
在这个方法中,我还指定如果第二个视图 (PhotoVC) 显示它也应该支持所有方向。
在我的第一个视图(HomeVC)中,我使用以下方法覆盖了此方法,以便在显示视图时仅支持纵向模式:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
不确定 iOS 7 在这方面发生了什么变化,因为在 iOS 6 中一切正常。似乎在 iOS 7 中,一旦弹出横向视图,应用程序就不会自动旋转回来。
任何帮助,将不胜感激..