簡體   English   中英

如何在Xcode 4.5中創建IOS 5.1應用程序

[英]How to create IOS 5.1 apps in Xcode 4.5

當我在Xcode 4.5上為IOS 5創建Ipad應用程序時遇到橫向問題我看到了一些相關的問題,但大多數都與我的情況相反。

我不使用像Bool autorotate這樣的代碼我只是選擇界面構建器上的landscape。 取消選擇使用autolayout。

當我創建應用程序時,我在項目文件夾中選擇IOS部署目標5.1(藍色圖標)

在此輸入圖像描述

構建設置是架構Base Sdk是IOS 6

在此輸入圖像描述

故事板導航控制器設置為橫向,界面文檔設置為5.1

在此輸入圖像描述

在IOS 6模擬器景觀中運行良好:

在此輸入圖像描述

但在IOS 5.1模擬器中,景觀不起作用且迷失方向

在此輸入圖像描述

我錯過了什么? 如何使這個版本適用於5.1和6版本?

編輯=====

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation==UIInterfaceOrientationLandscapeRight)
        return YES;

    return NO;
}

上面的代碼也不起作用。 它仍然是一樣的。

您應該在視圖控制器上覆蓋shouldAutorotateToInterfaceOrientation:並返回YES以獲得所需的方向,例如

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;

}

在IOS 6.0之前,您必須在項目的所有ViewControllers上覆蓋此方法。 在IOS 6中,Apple終於糾正了這種行為

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

}

使用以下代碼更新所有視圖控制器。

適用於Simulator 5.0及更高版本。

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskAll;
}

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM