我有一个 MainViewController,它有一个按钮,可以通过水平翻转推送新视图(InfoViewController)。像这样:
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
MainView 控制器支持 Portrait 和 PortraitUpsideDown。就像这样:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait |
UIInterfaceOrientationMaskPortraitUpsideDown);
}
在我的 InfoViewController 中它也声明了上面的代码。在我的 AppDelegate 中,LaunchOptions 中有以下内容:
[self.window setRootViewController:self.mainViewController];
在我的 app.plist 文件中,它支持所有方向。这是因为其他视图也需要支持景观。因此,在我的 MainViewController 和 InfoViewController 上,我只需要 Portrait 和 PortraitUpsideDown。但从另一个角度来看,我需要所有的排列。
我的 MainViewController 工作正常,但我的 InfoViewController 适用于所有方向。
我在尝试让它在 iOS6 中工作时遇到了极大的困难。我研究了其他帖子并尝试了其他人提供的帮助,但没有任何运气。请有人帮我实现这个目标,谢谢。我是 Objective-C 新手 :p
不支持应用程序 plist 文件中的所有方向,仅支持根视图控制器支持的方向。
自动旋转在 iOS 6 中发生了变化。在 iOS 6 中,shouldAutorotateToInterfaceOrientation:
UIViewController 的方法已被弃用。取而代之的是,您应该使用supportedInterfaceOrientationsForWindow:
and shouldAutorotate
方法:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
在 iOS 6 中,模态视图控制器不再获得旋转调用:
这willRotateToInterfaceOrientation:duration:,
willAnimateRotationToInterfaceOrientation:duration:,
and
didRotateFromInterfaceOrientation:
不再在任何进行全屏演示的视图控制器上调用方法
本身 - 例如那些被调用的:presentViewController:animated:completion:
.
您可以让呈现模态视图控制器的视图控制器通知它旋转。
另外,现在您使用:presentViewController:animated:completion:
呈现视图控制器。presentModalViewController:animated:
已弃用您在代码中使用的内容。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)