sho*_*eli 7 iphone orientation ios ios6 ios7
我有一个应用程序仅支持某些部分(照片库,视频等)的横向方向,并且所有在iOS 6上运行良好没有问题,但是,在iOS 7中应用程序崩溃.
所以继承我的问题:
Run Code Online (Sandbox Code Playgroud)--> 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{}
Run Code Online (Sandbox Code Playgroud)
在这个方法中,我指定如果第一个视图(HomeVC)显示它应该支持所有方向.
在这个方法中,我还指定如果第二个视图(PhotoVC)显示它也应该支持所有方向.
在我的第一个视图(HomeVC)中,我使用以下方法覆盖此方法,以便在显示视图时仅支持纵向模式:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
不确定iOS 7中有什么变化因为iOS 6中的一切都运行良好.似乎在iOS 7中,一旦弹出横向视图,应用程序就不会自动旋转.
任何帮助,将不胜感激..
小智 14
在IOS7中.如果你使用UINavigationController,旋转处理方式是不同的!
看到UINavigationController,可以看到它是UIViewController的子类,那就是在他上面列出了上面旋转的处理方法; 所以我需要使用UINavigationController也做旋转处理,
我的方法是添加一个类别到UINavigationController,这样做.
在类别中.M写道
-(BOOL)shouldAutorotate {
return [[self.viewControllers lastObject] shouldAutorotate];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8512 次 |
| 最近记录: |