强制UIViewController在iOS7中横屏模式下显示

3
我已经实现了正确的函数,但它们没有被触发?我在StackOverFlow尝试了几个解决方案,但它们都没有起作用。我尝试将视图添加到UINavigationController中,也不起作用。
FakeIDDetailViewController.h:
@interface FakeIDDetailViewController : UIViewController
@end

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;
}

你尝试过哪些 Stack Overflow 的解决方案?就像你所说的,有很多……我宁愿不一一列举。 - nhgrif
可能是重复的问题:https://dev59.com/hWIk5IYBdhLWcg3wp_iM - Xu Yin
尝试这个:https://dev59.com/T33aa4cB1Zd3GeqPhcDg#22491787 - Fede Cugliandolo
@Jim Clermonts 如果其中一个答案有帮助,您应该接受它。 - race_carr
2个回答

4
如果您正在将视图控制器推送到导航控制器中的其他视图控制器堆栈中,并要求仅横向显示,则效果不佳。您应该以模态方式显示横向约束的视图控制器。
请查看此处的答案,其中包含一个示例项目: https://dev59.com/RGUo5IYBdhLWcg3wkAHB#16022631

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接