2013-04-11 48 views
0

我爲iPhone和iPad開發了通用應用程序。 使用目標中的「支持的界面方向」選項(在Xcode項目中)我已經設置了所需的配置,一個用於iPhone,另一個用於iPad。 iPhone(5.1和6.1)沒有問題,但使用iPad我發現在5.1固件中,方向不正確(不像以前所寫的那樣)。對於使用iOS 6.1的iPad,應用程序可以正常工作。iPhone開發中的方向不正確

我讀過另一個stackoverflow的問題的解決方案:問題將是正確的,引入下面的代碼。

-(NSInteger)supportedInterfaceOrientations{ 
return UIInterfaceOrientationLandscapeRight; 
} 
// pre-iOS 6 support 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
return UIInterfaceOrientationLandscapeRight; 
} 

在我的情況下,問題仍然存在。我能怎麼做?

回答

1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight; 
} 

上述方法在你的情況總是返回YES(INT大於0),這樣,將不返回所有其它接口的方向。

雖然您可能想重構代碼以支持兩種橫向方向,但將視圖鎖定到僅一種橫向方向是一種不好的做法。