强制UIViewController处于横向模式iOS7 [英] force UIViewController to be in Landscape mode iOS7

查看:76
本文介绍了强制UIViewController处于横向模式iOS7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了适当的功能,但是不会触发它们吗?我在这里在StackOverFlow上尝试了几种解决方案,但是没有一个起作用.我尝试过将视图添加到UINavigationController中,这也不起作用.

I've implemented the proper functions, but they don't get triggered? I've tried several solutions here on StackOverFlow, but none of them work. I've tried adding the view to a UINavigationController, also doesn't work.

FakeIDDetailViewController.h:

FakeIDDetailViewController.h:

@interface FakeIDDetailViewController : UIViewController
@end

FakeIDDetailViewController.m:

FakeIDDetailViewController.m:

@interface FakeIDDetailViewController ()

-(BOOL)shouldAutorotate
{
    return NO;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (UIInterfaceOrientationMaskLandscapeLeft);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

- (NSUInteger) application:(UIApplication *)application     supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationLandscapeLeft;
}

推荐答案

如果将视图控制器推到导航控制器中的其他视图控制器的堆栈中,则仅要求横向操作不会很好.您应该以模态显示横向约束视图控制器.

If you are pushing a view controller to a stack of other view controllers in a navigation controller, requiring landscape only will not work well. You should display the landscape-constraint view controller modally.

在这里查看我的答案以获取示例项目: https://stackoverflow.com/a/16022631/983912

See my answer here for an example project: https://stackoverflow.com/a/16022631/983912

这篇关于强制UIViewController处于横向模式iOS7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆