1

找不到我的问题的答案:

我在 XCode 中创建了一个项目(仅选择横向)在 .xib 文件中创建设计也仅用于横向。但!!!当我在模拟器上开始我的项目时,我遇到了下一个问题:模拟器有横向位置,但所有元素都显示为纵向 =(

如何也改变它的景观?

因此,当我添加此代码来委派此问题时:

UIViewController *rootController = [[G2SwitchViewController alloc] init];
_navigationViewController = [[UINavigationController alloc]             initWithRootViewController:rootController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
[self.window addSubview:_navigationViewController.view];
[self.navigationViewController setNavigationBarHidden:YES];
[self.window makeKeyAndVisible];
return YES;
4

2 回答 2

0

您可以使用修复它

- (NSUInteger)supportedInterfaceOrientations //ios 6
{

    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation //ios 5
{


    if (UIInterfaceOrientationIsLandscape( interfaceOrientation)) {
        return  YES;
    }
    return NO;
}
于 2013-09-05T08:32:55.713 回答
0

您可以添加此代码

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


或者我们可以做一件事

  1. 转到目标文件 -> 单击摘要 -> 支持的设备方向

在这里我们可以选择我们期望的方向

单击纵向以取消选择它。

核实

于 2013-09-05T10:00:36.447 回答