ios7 - 在一个 View Controller 中强制横向方向

标签 ios7 autorotate

在 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/

相关文章:

ios - NSURLSession + 带有自签名证书的服务器

ios - 当图像及其按钮旋转时,相机应用程序如何防止其工具栏旋转?

ios - 在 -shouldAutorotateToInterfaceOrientation : 中预测 UI 元素框架

ios - 模态视图 Controller 在 iOS 7 上工作,在 iOS 6 上留下一个空白

iphone - iOS7 中的导航栏颜色不同?

ios - 在后台下载期间未调用我的 NSURLSessionDelegate 方法

更改监听器时的android自动旋转配置

android map 自动旋转

ios - 如何让 MPMoviePlayerController 的 View 在非全屏时在旋转时调整大小

iOS 7 UIWebView 304 缓存错误,空白页面