2012-07-12 56 views
1

可能重复:
Landscape Mode ONLY for iPhone or iPad修改iPhone到部队横向方向只有

我工作的一个项目,以重新利用旧的iPhone作为汽车媒体中心。我特别需要获得某种教程或通过专门指定修改默认iOS屏幕方向所需的步骤。

很多人都使用Cydia的横向旋转锁来禁用横向模式,我的目标恰恰相反。

我想禁用纵向模式,因为最终结果会将iPhone水平安装在我的汽车中,因此只需要横向方向。

这怎么办?

+3

一样,http://stackoverflow.com/questions/5777313/xcode-how-to-build-a-landscape-only-iphone-programe – Devraj 2012-07-12 03:54:11

+0

您可以轻松地“硬线“你的应用只能看到风景。但我猜测没有办法强制手机显示一切景观。 – 2012-07-12 04:06:48

回答

0

试试这个

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
} 
+0

呃,他可能只想要这些方向之一,否则图像可能会颠倒。 – 2012-07-12 04:07:27

+0

@HotLicks然后他可以从返回语句中删除Or部分。 – 2012-07-12 04:10:55

+0

感谢您的输入人。如果你检查这个链接http://stackoverflow.com/questions/3176577/remove-ability-for-portrait-orientation-for-app-in-iphone-sdk它看起来代码已经在那里。我是一个xcode处女,所以我不知道从哪里开始或如何到达修改此代码的地步。 – 2012-07-12 04:24:28

0

使用Supported interface orientationsLandscape (left home button)并在Info.plist文件中设置它的值。这将启动你的应用程序在这个方向,你需要设置

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

在每个viewController。

希望这是你在找什么。需要帮助请叫我。

更新

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

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 

这将返回是只在你的风景左模式。如果你想同时景观左,右使用

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

此代码将进入你的每一个的viewController的shouldAutorotateToInterfaceOrientation方法。

希望它能帮助:)

+0

我没有应用程序。我指的是修改设备本身的用户界面。 – 2012-07-12 05:01:50