問(wèn)題描述
我正在為 iOS 5 開(kāi)發(fā)一個(gè)應(yīng)用程序,它必須在橫向模式下運(yùn)行.我的問(wèn)題是我最初無(wú)法讓它翻轉(zhuǎn).
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.
我已經(jīng)嘗試將初始界面方向"設(shè)置為橫向(右主頁(yè)按鈕)"并將以下方法添加到我的視圖控制器:
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);
}
我可以理解它應(yīng)該如何工作.(我找到了代碼 這里)
I can wrap my head around how it is supposed to work. (I found the code here)
我也想知道如何使用 Xcode 4.2 項(xiàng)目設(shè)置中提供的支持的設(shè)備方向",它似乎沒(méi)有做任何事情.
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.
我一直在瀏覽網(wǎng)站,但找不到解決我問(wèn)題的示例.
I have been looking around the website and have not been able to find an example that solves my problem.
謝謝.
推薦答案
在應(yīng)用程序的 Info.plist 文件中,添加 UIInterfaceOrientation
鍵并將其值設(shè)置為橫向模式.景觀方向,您可以設(shè)置值這把鑰匙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
.
以橫向模式布置視圖,并確保其自動(dòng)調(diào)整大小選項(xiàng)設(shè)置正確.
Lay out your views in landscape mode and make sure that their autoresizing options are set correctly.
覆蓋您的視圖控制器的 shouldAutorotateToInterfaceOrientation:
方法并僅對(duì)所需的橫向和否用于縱向.
Override your view controller’s shouldAutorotateToInterfaceOrientation:
method and return YES only for the
desired landscape orientation and NO
for portrait orientations.
這篇關(guān)于強(qiáng)制 iOS 應(yīng)用以橫向模式啟動(dòng)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!