2010-08-19 55 views
0

我有一款應用程序,它是一款遊戲,它不適合在橫向上使用。iPad上的UIInterfaceOrentation

現在我的代碼是:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
// Overriden to allow any orientation. 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 

}

並允許只在畫像(上底部home鍵)上運行,我希望它在縱向的(Home鍵上運行底部或頂部),所以蘋果接受它。

我曾嘗試:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Overriden to allow any orientation. 
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

,並沒有工作...... 能有人給我的代碼,以便它在縱向模式下運行,使之。

回答

0

您只能返回一次,所以第二個返回語句永遠不會被評估。使其成爲一個布爾OR:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Overriden to allow any orientation. 
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) || (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

也有縱向和橫向的宏,但這應該工作得很好。