2010-02-01 71 views
0

如何強制它僅顯示在UIDeviceOrientationPortrait上?在UIInterfaceOrientationLandscapeLeft如何在iPhone上以編程方式強制interfaceOrientation?

例如 層1顯示,當我pushViewController到二層它將在UIInterfaceOrientationLandscapeLeft 車展我怎樣才能迫使它顯示UIDeviceOrientationPortrait?

+0

Mybe這將幫助:http://stackoverflow.com/a/10146270/894671 – 2012-04-18 20:38:06

回答

2

只需在您的視圖控制器中實現shouldAutorotateToInterfaceOrientation:

1

把你的二層的viewController如下:

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
0

我已經受夠了這種麻煩。設置shouldAutorotateToInterfaceOrientation:將viewControllers推入堆棧將導致它們的視圖正確定向,但是您不能通過顯式函數調用來確定縱向或橫向的方向。

到目前爲止,我見過的最好的方法是自己處理動畫(使用CATransform和相關的CoreAnimation調用)。這並不漂亮。

如果有人知道強制視圖旋轉的方式(即沒有按下/彈出視圖控制器,並且沒有旋轉實際設備),請讓我/我們知道。

相關問題