1

Possible Duplicate:
Landscape Mode ONLY for iPhone or iPad

I'm working on a project to repurpose old iPhones as media hubs in cars. My particular need is obtaining some sort of tutorial or walk through specifically designating the steps needed to modify the default iOS screen orientation.

Many people have used the Landscape Rotation Lock in Cydia to disable Landscape mode, my goal is just the opposite.

I'd like to disable Portrait mode, as the end result will see the iPhone mounted in my car horizontally, thus requiring Landscape orientation only.

How can this be done?

4

2 回答 2

0

Supported interface orientationsLandscape (left home button)info.plist 文件中使用并设置其值。这将以该方向启动您的应用程序,您需要设置

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

在每个视图控制器中。

希望这是您正在寻找的。需要帮助请叫我。

更新

嗨@DanSolo,我认为您的应用程序是在 XCode 中创建的,对吗?如果是这样,则转到您的任何视图控制器并检查该shouldAutorotateToInterfaceOrientation方法。旋转设备时将调用此方法。如果您将返回 Yes ,它将不会旋转。在您的情况下,您将返回

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

这将仅在您的横向左侧模式下返回 Yes。如果你想要左右横向使用

return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
        (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

此代码将进入您的每个 viewController 的shouldAutorotateToInterfaceOrientation方法中。

希望能帮助到你 :)

于 2012-07-12T04:22:56.620 回答
0

尝试这个

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
于 2012-07-12T04:06:42.393 回答