2011-05-13 28 views
0

我正在使用xCode 4作爲我的項目,它應該可以在iPad和iPhone上使用。所以,我創建了基於通用窗口的應用程序。我想我的應用程序開始進入橫向模式,所以我補充如下: 的方法:Xcode 4組件方向問題

shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

我設置interfaceOrientation == UIInterfaceOrientationLandscapeRight 並添加鑰匙插進application.plist: Initial Interface Orientation,並設置景觀(右home鍵)。

現在,應用程序確實以橫向模式啓動,但其中的每個組件(按鈕,標籤)仍然旋轉90度(逆時針)。 當我加載xib時,窗口方向設置爲縱向,下拉禁用。 有人有想法我做錯了什麼?

回答

0

shouldAutorotateToInterfaceOrientation不要求您設置變量(並且即使您這樣做也無法讀取結果),這是查詢提名方向是否可接受的問題。所以你想:

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

/* or: return interfaceOrientation == UIInterfaceOrientationLandscapeRight; */ 

該XIB是一個單獨的問題; Interface Builder及其替代部件在Xcode 4中都不能看到你在代碼中做了什麼,所以他們不應該拒絕讓你在橫向模式下進行設計。但是,它是與相關UIViewController的視圖成員關聯的視圖,您要設置方向,而不是窗口。