强制iOS应用以横向模式启动 [英] Force iOS app to launch in landscape mode

查看:115
本文介绍了强制iOS应用以横向模式启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iOS 5开发一个必须以横向模式运行的应用程序。我的问题是我最初无法翻转它。

I am developing an app for iOS 5, which have to run in landscape mode. My problem is that I cannot get it to flip initially.

我尝试将初始界面方向设置为横向(右侧主页按钮)
并将以下方法添加到我的视图控制器:

I have tried the adding "Initial interface orientation" set to "Landscape (right home button)" and adding the following method to my view controller:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

我可以理解它应该如何工作。 (我发现代码这里

I can wrap my head around how it is supposed to work. (I found the code here)

我也想知道如何使用Xcode 4.2项目设置中提供的支持的设备方向,它似乎没有做任何事情。

I am also wondering how to use the "Supported Device Orientation" available in the Xcode 4.2 project setup, it does not seem to do anything.

我一直在寻找网站,但未能找到解决我问题的例子。

I have been looking around the website and have not been able to find an example that solves my problem.

谢谢。

推荐答案

在应用程序的Info.plist文件中,添加 UIInterfaceOrientation
键并将其值设置为
横向模式。对于横向
方向,您可以将此键的值
设置为
UIInterfaceOrientationLandscapeLeft

UIInterfaceOrientationLandscapeRight

In your application’s Info.plist file, add the UIInterfaceOrientation key and set its value to the landscape mode. For landscape orientations, you can set the value of this key to UIInterfaceOrientationLandscapeLeft or UIInterfaceOrientationLandscapeRight.

以横向模式布置视图,并确保正确设置其自动调整大小选项。

Lay out your views in landscape mode and make sure that their autoresizing options are set correctly.

覆盖视图控制器的 shouldAutorotateToInterfaceOrientation:方法,仅返回
所需的横向和NO
用于纵向方向。

Override your view controller’s shouldAutorotateToInterfaceOrientation: method and return YES only for the desired landscape orientation and NO for portrait orientations.

这篇关于强制iOS应用以横向模式启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆