在 iOS 5 和 6 中,我在 View Controller 的 viewWillAppear 方法中执行此操作:
UIViewController *c = [[UIViewController alloc] init];
//To avoid the warning complaining about the view not being part of the window hierarchy
[[[TWNavigationManager shared] window] addSubview:c.view];
[self presentModalViewController:c animated:NO];
[self dismissModalViewControllerAnimated:NO];
[c.view removeFromSuperview];
我还在应用程序委托(delegate)中添加了此方法
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return [[TWNavigationManager shared] supportedInterfaceOrientationsForTopViewController];
}
这基本上将该调用转发到顶 View Controller 。
这导致为我的 View Controller 调用自动旋转方法,然后我能够为该 View Controller 强制横向方向。 现在,在 iOS 7 中,该代码不再起作用。全屏显示白色 View 。
iOS7 中正确的方法是什么?
提前致谢。
最佳答案
遇到了同样的问题,并设法通过关闭呈现的模态视图动画来解决它:是。
[self dismissViewControllerAnimated:YES completion:nil];
希望有帮助!
关于ios7 - 在一个 View Controller 中强制横向方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18980853/