objective-c – 强制UIViewController处于横向模式iOS7

前端之家收集整理的这篇文章主要介绍了objective-c – 强制UIViewController处于横向模式iOS7前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经实现了正确的功能,但它们没有被触发?我在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;
}

解决方法

如果要将视图控制器推送到导航控制器中的其他视图控制器堆栈,则仅需要横向将无法正常工作.您应该以模态方式显示横向约束视图控制器.

有关示例项目,请参阅此处的答案:
https://stackoverflow.com/a/16022631/983912

猜你在找的Xcode相关文章