2012-03-02 61 views
0

我想我的應用程序支持PortraitUpSideDown方向。 我已經改變了info.p名單,以反映這一點,並試圖執行一個視圖改變爲測試UIInterfaceOrientation Xcode

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

} 

但鑑於沒有響應。 在應用程序響應之前,我是否需要在所有視圖上實現此功能? 是否有需要更改的Xib設置?

+0

這不是一個Xcode問題。這是一個____問題,你用你正在使用的顯示庫來填充空白。 – Almo 2012-03-02 19:49:33

回答

5

如果你想同時支持橫向模式,請嘗試以下操作:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); 
} 

或者:

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

或者出頭,看起來像你試圖寫:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if (interfaceOrientation == UIInterfaceOrientationPortrait) { 
     return YES; 
    } 
    if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { 
     return YES; 
    } 
    return NO; 
} 
+0

+1第二個片段更清潔:) – dasblinkenlight 2012-03-02 19:52:58

+0

感謝sch爲這些解決方案應用程序似乎沒有迴應它是一個標籤欄應用程序也許這與它有什麼關係? – MacUser 2012-03-02 20:36:56

+0

@sch最後一段代碼片段在蘋果論壇中與以下解決方案配合使用:https://discussions.apple.com/message/8544354#8544354 感謝您的幫助! – MacUser 2012-03-02 21:27:30

相關問題